Skip to main content
2 of 4
added 281 characters in body
Gajus
  • 1.3k
  • 2
  • 16
  • 29

How do I round time to the upper multiple of an arbitrary time interval?

Example:

  • If the current time is 2018-05-17 22:45:30 and the desired interval is INTERVAL '10 minute', then the desired output is 2018-05-17 22:50:00.
  • If the current time is 2018-05-17 22:45:30 and the desired interval is INTERVAL '1 hour', then the desired output is 2018-05-17 23:00:00.
  • If the current time is 2018-05-17 22:45:30 and the desired interval is INTERVAL '1 day', then the desired output is 2018-05-18 00:00:00.
Gajus
  • 1.3k
  • 2
  • 16
  • 29