Oracle Timestamp: extract full hour
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 thi开发者_C百科s 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
SELECT TRUNC(m.begin, 'HH24')
FROM mytable m
You can use the TRUNC() function:
http://www.psoug.org/reference/date_func.html
精彩评论