开发者

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜