Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Highlighted
un_check24
New Contributor

Grouping time to morning, noon and evening

Dear community,

I have a field called 'visit_last_action_time' which delivers me the exact user's time of last action, formatted as "hh:mm:ss" (e.g. "10:03:03")

Now I want to group these time stamps into Morning, Noon and Evening.


I tried the if function:

=if (visit_last_action_time > '12:00:00', 'Morning')

but it does not work properly, since the time stamps of different dates are not clustered together.

Can anyone help me?

Thank you so much in advance!

Best


Philipp

1 Solution

Accepted Solutions
el_aprendiz111
Valued Contributor

Re: Grouping time to morning, noon and evening

Hi

1 example

dual(timestamp(class(frac(visit_last_action_time ),480/(24*60)),'h:mm TT') & ' - ' & timestamp(class(frac(visit_last_action_time )+480/(24*60),480/(24*60)),'h:mm TT'), class(frac(visit_last_action_time ),480/(24*60))) as Betwen_HRS

View solution in original post

4 Replies
el_aprendiz111
Valued Contributor

Re: Grouping time to morning, noon and evening

Hi

1 example

dual(timestamp(class(frac(visit_last_action_time ),480/(24*60)),'h:mm TT') & ' - ' & timestamp(class(frac(visit_last_action_time )+480/(24*60),480/(24*60)),'h:mm TT'), class(frac(visit_last_action_time ),480/(24*60))) as Betwen_HRS

View solution in original post

Re: Grouping time to morning, noon and evening

May be try this

If(Frac(visit_last_action_time) < MakeTime(12), 'Morning',

     If(Frac(visit_last_action_time) = MakeTime(12), 'Noon', 'Evening')) as Period

I am assuming that till 11:59 AM, it is morning and 12 pm is Noon and after that is evening..... change these according to your needs

un_check24
New Contributor

Re: Grouping time to morning, noon and evening

Thanks so much to you guys, both worked and gives me some great new insights :-)!!

Re: Grouping time to morning, noon and evening

Awesome, please close this thread by marking correct and helpful responses.

Qlik Community Tip: Marking Replies as Correct or Helpful

Best,

Sunny