Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
LeeSpears
Contributor
Contributor

Round datetime value to date and hourly bucket

My original data contains a 'time' field with epoch timestamp values such as:
1674428490776

I've already used scripting to convert these into human readable timestamps in the 'toa' field as follows:
date((time/24/60/60/1000) + 25569,'YYYY-MM-DD HH:mm:SS') as toa

And this gives values such as:
2023-01-23 12:06:40

What I want is to round down the time to the nearest hour in the 'toa' field so that I get values such as:
2023-01-23 12:00
(in 24-hour format)

The point of this is that I want to create a time series chart showing the number of widgets produced per hour over my desired length of time, which may be hours, days, weeks, etc.

Thank you!

Labels (5)
1 Solution

Accepted Solutions
SerhanKaraer
Creator III
Creator III

Hello Lee,

Try this:

 

date(floor((time/24/60/60/1000) + 25569,1/24),'YYYY-MM-DD HH:mm')

 

View solution in original post

1 Reply
SerhanKaraer
Creator III
Creator III

Hello Lee,

Try this:

 

date(floor((time/24/60/60/1000) + 25569,1/24),'YYYY-MM-DD HH:mm')