# QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

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

Tags (3)
1 Solution

Accepted Solutions
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

4 Replies
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

MVP

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

Highlighted
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 :-)!!

MVP