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

Home -> Community -> Usenet -> c.d.o.server -> Re: trunc sysdate

Re: trunc sysdate

From: <fitzjarrell_at_cox.net>
Date: Wed, 06 Jun 2007 14:17:41 -0700
Message-ID: <1181164661.550982.298050@d30g2000prg.googlegroups.com>


On Jun 6, 4:04 pm, "klabu" <k..._at_mailinator.com> wrote:
> 10gR2/Solaris 8
>
> how to trunc seconds off sysdate ?
>
> so it returns like this : "06-06-2007 05:12:00" instead of "06-06-2007
> 05:12:18"
>
> thanks

You can't selectively 'truncate' bits and pieces of the time component from SYSDATE using trunc(); it's all or nothing. You could go 'round about the bush by converting SYSDATE to a character string and converting it back:

SQL> alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS';

Session altered.

SQL> select sysdate, to_date(to_Char(sysdate, 'DD-MON-YYYY HH24:MI'), 'DD-MON-YYYY HH24:MI')
   2 from dual;

SYSDATE TO_DATE(TO_CHAR(SYSD

-------------------- --------------------
06-JUN-2007 16:12:46 06-JUN-2007 16:12:00 SQL> Which is an obvious 'solution'.

David Fitzjarrell Received on Wed Jun 06 2007 - 16:17:41 CDT

Original text of this message

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