Oracle query Round up or down to nearest 15 minute interval

08-SEP-20 08:55:05
08-SEP-20 15:36:13

The query below is working correctly for 15:36:13 in that it rounds to 15:30 but the 8:55:05 is rounding down to 08:45 when it should be rounding to 09:00

select event_date,trunc(event_date,'mi') - numtodsinterval(  mod(to_char(event_date,'mi'),15),  'minute'  ) as nearest_quarter
from time_source_in_all where empno = '002307718' and event_date between  '8-sep-2020' and '9-sep-2020'

Read more here:

Content Attribution

This content was originally published by JayMaker at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: