views:

137

answers:

2

I need to extract the 'full' hour of a timestamp. Like for 2010.03.04 13:13 I want 2010.03.04 13:00 (as a timestamp again).

My current approach is:

TO_TIMESTAMP(TO_CHAR(m.begin, 'yyyy.mm.dd hh24'), 'yyyy.mm.dd hh24')

Is this really the way to go? Who good/bad does it perform (I plan to do a GROUP BY on it).

Thanks for your input!

Cheers, Reto

+5  A: 
SELECT  TRUNC(m.begin, 'HH24')
FROM    mytable m
Quassnoi
Thanks! Perfect..
reto
+1  A: 

You can use the TRUNC() function:

http://www.psoug.org/reference/date_func.html

Álvaro G. Vicario