Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Time is cut off from sysdate using PL/SQL
Hi.
Doing a to_date of a date can be dangerous. In
certain circumstances (dependent on your default
nls_date_format), you can unknowingly set the
century incorrectly.
Thus, it is never recommended to do a to_date of a date.
You'll see Oracle's comment to this effect as well in the
SQL reference guide.
Cheers
Coakleyj
In article <7mk59i$a08$1_at_nnrp1.deja.com>,
Peter C. <pcugier_at_my-deja.com> wrote:
> I discovered that the time part of sysdate is cut of using sysdate in a
> to_date function in a PL/SQL procedure.
> If you first select sysdate into a local variable it doesn't happen.
> Is this a normal behaviour of PL/SQL or more like a bug?
>
> Here's a sample program which explains what I mean.
>
> SQL> DECLARE
> 2 date1 DATE;
> 3 date2 DATE;
> 4 BEGIN
> 5 date1 := TO_DATE(SYSDATE, 'DD.MM.RRRR HH24:MI:SS');
> 6
> 6 SELECT sysdate
> 7 INTO date2
> 8 FROM dual;
> 9
> 9 DBMS_OUTPUT.PUT_LINE ('Date1: '||TO_CHAR(date1, 'DD.MM.RRRR
> HH24:MI:SS'));
> 10 DBMS_OUTPUT.PUT_LINE ('Date2: '||TO_CHAR(date2, 'DD.MM.RRRR
> HH24:MI:SS'));
> 11
> 11 END;
> 12 /
> Date1: 14.07.1999 00:00:00
> Date2: 14.07.1999 18:22:34
>
> PL/SQL procedure successfully completed.
>
> SQL>
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
Received on Fri Jul 16 1999 - 04:38:46 CDT
![]() |
![]() |