Skip to main content

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
QlikWorld 2023, a live, in-person thrill ride. Save $300 before February 6: REGISTER NOW!
cancel
Showing results for 
Search instead for 
Did you mean: 
its_rajvir
Contributor III
Contributor III

Time Intervals

Dear Experts,

I am trying to create a field with half hour intervals from time field like this :

7:00 to 7:30
7:30 to 8:00
8:00 to 8:30
8:30 to 9:00
9:00 to 9:30
9:30 to 10:00........

I tried this:

Time(floor([TimeField],(1/48)),'hh:mm') & ' to ' & Time(ceil([TimeField],(1/48)),'hh:mm') as HalfHour Interval.

But it is giving me wrong output like this:

7:00 to 7:00
7:00 to 7:30
7:30 to 8:00
8:00 to 8:00
8:00 to 8:30
8:30 to 9:00
9:00 to 9:00
9:00 to 9:30
9:30 to 10:00

Kindly help me to get the correct output.

Thank You 

 

 

 

 

 

 

1 Solution

Accepted Solutions
hic
Employee
Employee

If the value of TimeField exactly corresponds to the full hour, then Floor() and Ceil() will return the same number. Compare with 

Floor(5) = Ceil(5) = 5

Instead, you could try 

Time(Floor(48*TimeField)/48,'hh:mm') & ' to ' & Time(Floor(48*TimeField+1)/48,'hh:mm') as HalfHour,

HIC

View solution in original post

2 Replies
hic
Employee
Employee

If the value of TimeField exactly corresponds to the full hour, then Floor() and Ceil() will return the same number. Compare with 

Floor(5) = Ceil(5) = 5

Instead, you could try 

Time(Floor(48*TimeField)/48,'hh:mm') & ' to ' & Time(Floor(48*TimeField+1)/48,'hh:mm') as HalfHour,

HIC

its_rajvir
Contributor III
Contributor III
Author

Thankyouu so Much @hic 😊