N
N
NubasLol2019-12-09 14:46:07
PostgreSQL
NubasLol, 2019-12-09 14:46:07

How to round time in increments of 15 minutes?

For example 14:44:43 = 14:45:00. For example 14:24:43 = 14:30:00

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
NubasLol, 2019-12-09
@NubasLol

found a solution

(date_trunc('hour', (now() AT TIME ZONE 'Europe/Moscow')::time) +
        ceil(date_part('minute', (now() AT TIME ZONE 'Europe/Moscow')::time)::decimal / 15) * interval '15 min')::time

A
Anton Shamanov, 2019-12-09
@SilenceOfWinter

time as a TIME string or a TIMESTAMP number?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question