Check time and display the slot assigned - time

I have the following table
Start Time End Time Time Slot
00:00 05:59 TS1
06:00 11:59 TS2
12:00 17:59 TS3
18:00 23:59 TS4
So when input time is 06:45 , expected the results show is "TS2"
Anyone can share with me how to solve this with excel.
Thanks
spend an hour try different way with if statement but can get the results

Related

Storing Tim in Database

I am trying to add the time with AM/PM into the database with 12HRS format but it is only storing the time like 10:10 or 13:45 and i need like 10:10 AM OR 3:45 PM etc.. like.
<input type="time" name="time">
$time=strtotime($_POST['appt']);
how i will insert like 10:10 AM OR 3:45 PM etc.. in database
how i will insert into database with 12 hrs format and with AM/PM

Convert Date strored as number(32,0) in oracle

I have an issue importing date from a Tririga database into a SQL database. Mainly I cant convert the date properly and it looks like is not the commont format I have seen around.
Eg date value incomming 775724400000
Running something like select to_date('765187200000', 'DDMMYYYYHH24MISS') my_date FROM dual;
give me an error
ORA-01847: day of month must be between 1 and last day of month
01847. 00000 - "day of month must be between 1 and last day of month"
I found the following info from this link seems to be also from tririga
link_help
And the size of the number are about 10 digits meanwhile this one is 12 and I know for fact this dates should be from the past 10 years (most of them)
I can't seem to find anything that gives me an answer how to convert this into proper dates.
Any suggestions?
The input number appears to be "epoch", a count of milliseconds elapsed since 1 January 1970 GMT (UTC).
To convert to date is not difficult:
select date '1970-01-01' + (775724400000 / 86400000) as dt from dual;
DT
--------------------
1994-Aug-01 07:00:00
Note the hard-coded literals: date '1970-01-01' (epoch is by definition measured from midnight on this date) and 86400000. By one of the definitions (in the previous version of the International System of Units and Weights), a second is 1/86400 of a median day. In Oracle, date arithmetic is based on the number 1 representing one day, so to convert your milliseconds to days you must divide your input by 86400 * 1000.
The most delicate question has to do with time zones (and possibly daylight saving time, also related to time zone). In most cases, epoch is measured from midnight on 1 January 1970 GMT, not from midnight on 1 January 1970 in local time. Do you need to adjust for that? Only you and your business users can answer that question.
(As an aside, the number you provided does NOT represent a date in the past 10 years - not even close.)

Find all customers who engaged continuously for 6 months

I need code help in Oracle
I have table with the following structure. This is an aggregate table grouped by Account_ID and month (month rolled to the start date of the month) and number of transactions performed in that month.
Account_ID Date Trans_cnt
------------------------------
A00001 01Jan2018 12
A00002 01Jan2018 14
A00002 01Feb2018 01
A00003 01Feb2018 02
A00001 01Mar2018 12
I need to find accounts which have had continuous 6 months of transaction and 3 months of transactions
an example if account A00001 is analyzed for 6 months, then in a given year's time say from Jan 2018 to Dec 2018, this account should have continuous transactions from Jan to Jun or Feb to Jul; or Mar to Aug likewise.
Let me know how to come up with a sql for the same.

Last Sunday of March and October

I want to populate a table ---one column having the date for last Sunday of March and October for each year from 1800 to 2050 ..
Can someone help?
Thanks in advance
SELECT NEXT_DAY(LAST_DAY(SYSDATE)-7, 'SUN') FROM DUAL;
This gives the last date of the current month.
You just need to loop through the months instead of just giving SYSDATE.

Oracle week of the year

Why 12/16/2013 and 12/17/2013 are in different week?
alter session set NLS_TERRITORY=AMERICA;
select to_char(to_date('12-16-2013', 'mm-dd-yyyy'),'ww'),to_char(to_date('12-17-2013', 'mm-dd-yyyy'),'ww') from dual
If you look at the formatting models documentation, it states:
WW - Week of year (1-53) where week 1 starts on the first day of the
year and continues to the seventh day of the year.
W - Week of month (1-5) where week 1 starts on the first day of
the month and ends on the seventh.
01/01/2013 started on a Tuesday last year, not the first day of week. So in your test case, 12/17/2013 was on a Tuesday also, and a new "week" as oracle calculates it. Certainly, non-obvious.

Resources