Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: how to trunc date column to half an hour

Re: how to trunc date column to half an hour

From: Greg Rahn <greg_at_structureddata.org>
Date: Tue, 06 Mar 2007 10:59:07 -0800
Message-ID: <45EDB9FB.4010700@structureddata.org>


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-l
Received on Tue Mar 06 2007 - 12:59:07 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US