Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
How do I write a code to create interval for timings? For Example:
7:00:00 AM to 9:00:00AM --> "Early Morning"
17:00:00 PM to 21:00:00 --> "Early Evening"
time are in hh:mm:ss format...
@rllysm0ll if your Time field is in proper time format try below. If it is text, format it in Time using Time# function.
LOAD *,
if(TimeField>=MakeTime(7,0,0) and TimeField<= MakeTime(9,0,0),'Early Morning',
if(TimeField>=MakeTime(17,0,0) and TimeField<= MakeTime(21,0,0),'Early Evening')) as GroupTimeField
If(Time#(TimeField,'hh:mm:ss TT') >= Time#('7:00:00 AM','hh:mm:ss TT') and Time#(TimeField,'hh:mm:ss TT') <= Time#('9:00:00 AM','hh:mm:ss TT'),'Early Morning',
If(Time#(TimeField,'hh:mm:ss TT') >= Time#('17:00:00 PM','hh:mm:ss TT') and Time#(TimeField,'hh:mm:ss TT') <= Time#('21:00:00 PM','hh:mm:ss TT'),'Early Evening')) as [Parts of the Day]
@rllysm0ll if your Time field is in proper time format try below. If it is text, format it in Time using Time# function.
LOAD *,
if(TimeField>=MakeTime(7,0,0) and TimeField<= MakeTime(9,0,0),'Early Morning',
if(TimeField>=MakeTime(17,0,0) and TimeField<= MakeTime(21,0,0),'Early Evening')) as GroupTimeField