Time to next quarter hour
![00liolio00](https://us.v-cdn.net/6037124/uploads/userpics/MYDI7BL4P5YD/n8IB4OJHR7TDK.jpg)
Hi,
I have a "now" variable that gives me the current time.
I would like this variable to give me the time of the next quarter hour.
Examples
- If it is 03:12, the variable must be 03:15
- If it is 07:25 the variable must be 07:30
Do you have any idea how I can proceed?
Thanks :-)
Answers
-
You can use the transform_timestamp filter, which lets you work with relative time. Take a look at the formats available - this should be doable.
https://docs.xano.com/working-with-data/data-type-filters/timestamp-filters#transform_timestamp
-
Thanks for the answer @Sean Montgomery
I looked at this solution but the quarter hour doesn't seem possible.
Moreover, for information, the link in the article to the relative times format is in error 404.So I solved my problem as follows:
- I isolated the minutes and I divide these by 15.
- I use "ceil" to round the value.
- I multiply by 15
- I reconstruct my "now" via an extraction of the set without the minutes that I introduce by concatenation.
Maybe my solution can help others :-)
Good evening !
-
SInce a timestamp is a number milliseconds, and a quarter-hour is 15 minutes, which is 900 seconds, which is 900,000 milliseconds, you can also:
timestamp |divide 900000 | ceil | multiply 900000 to get the current time rounded up to the next quarter-hour.
Here's a screenshot of it in Xano:
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback