I have a DATE
column that I want to round to the next-lower 10 minute interval in a query (see example below).
I managed to do it by truncating the seconds
To return the next upper 10 minute interval, I used the following query. I hope it'll be useful because I couldn't simply do a
trunc(sysdate, 'mi') + mod(EXTRACT(minute FROM cast(sysdate as timestamp)), 10) / (24 * 60)
I did this and it worked for me.
select
case when mod(EXTRACT(minute FROM cast(sysdate as timestamp)),5) between 1 and 4
then trunc(sysdate,'mi')+((5*TRUNC(EXTRACT(minute FROM cast(sysdate as timestamp))/5,
0)+5)-EXTRACT(minute FROM cast(sysdate as timestamp)))/1440
else trunc(sysdate,'mi')
end
from dual
This is based on this post.