Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: how to trunc date column to half an hour
You didn't give the algorithm but something like this may work:
select
to_char(sysdate,'yyyy-mm-dd hh24:mi'),
case when to_number(to_char(sysdate,'mi')) between 0 and 29
then to_char(sysdate,'yyyy-mm-dd hh24')||':00'
else
to_char(sysdate,'yyyy-mm-dd hh24')||':30'
end
from dual;
This "rounds back", if you want to round you may have to adjust it to increase the hour as well.
Regards,
Greg Rahn
http://structureddata.org
-- http://www.freelists.org/webpage/oracle-lReceived on Tue Mar 06 2007 - 12:59:07 CST
![]() |
![]() |