Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
rllysm0ll
Contributor
Contributor

Date grouping

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...

Labels (1)
1 Solution

Accepted Solutions
Kushal_Chawda

@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

View solution in original post

2 Replies
BrunPierre
Partner - Master
Partner - Master

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]

Kushal_Chawda

@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