Skip to Main Content

SQL & PL/SQL

Rounding time to nearest hourly quarter

zebangoMar 9 2010 — edited Jul 6 2011
I have several records like

2/19/2010 1:25:46.000000 PM
2/19/2010 1:40:46.000000 PM
2/19/2010 1:55:46.000000 PM
2/19/2010 2:10:46.000000 PM

I want to round them off to the nearest quarter like
2/19/2010 1:30:00.000000 PM
2/19/2010 1:45:00.000000 PM
2/19/2010 2:00:00.000000 PM
2/19/2010 2:15:00.000000 PM

Any ideas how I would do that? a trunc(col,'mi) only lets me round it to the minute..

Note that records are not necessarily in the 5 minute interval difference it can also be 7 minute difference or 4 minute difference from the nearest quarter...

so I can also have records like
SysUpTime 2/19/2010 10:31:00 PM
SysUpTime 2/19/2010 10:57:00 PM
SysUpTime 2/19/2010 11:31:00 PM

etc.

Edited by: zebango on Mar 9, 2010 4:16 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 3 2011
Added on Mar 9 2010
10 comments
30,812 views