Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: to_date/to_char
<jeanch_at_my-deja.com> wrote in message news:8bt9ub$4gd$1_at_nnrp1.deja.com...
> Folks,
>
> Why is is that I get different results with the following:
> DECLARE
> d varchar2(50);
> BEGIN
> d := TO_CHAR(sysdate,'DD-MON-YY HH24:MI:SS');
> dbms_output.put_line(d);
> END;
>
> >>>29-MAR-00 17:20:50
>
> AND
>
> DECLARE
> d DATE;
> BEGIN
> d := TO_DATE(TO_CHAR(sysdate,'DD-MON-YY HH24:MI:SS'), 'DD-MON-
> YYHH24:MI:SS');
> dbms_output.put_line(d);
> END;
>
> >>>29-MAR-00
>
> The format is the same in both code:
> I was expecting to see the time on both but it's truncated
> Why y
>
> Cheers
> JC
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Simple.
As d is a date column, you are getting implicit conversion in your
dbms_output call.
The default date format is dd-mon-yy, which is exactly what you are getting
returned.
Hth,
Sybrand Bakker, Oracle DBA
Received on Wed Mar 29 2000 - 11:49:53 CST
![]() |
![]() |