Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: trunc sysdate
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