开发者

Oracle Timestamp: extract full hour

开发者 https://www.devze.com 2022-12-22 08:54 出处:网络
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).

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

0

精彩评论

暂无评论...
验证码 换一张
取 消