Home » SQL & PL/SQL » SQL & PL/SQL » Sysdate
Sysdate [message #40961] Thu, 14 November 2002 11:04 Go to next message
Nicola
Messages: 14
Registered: March 2002
Junior Member
HI!

I have a trigger with a row like this:
INSERT INTO TABLE_LOG (TIMESTAMP) VALUES (SYSDATE)

TIMESTAMP is a DATE field.
I need the complete date + time info.
After some time running, I got some records with date+time, but a lot of records with only the date and no time information.
Does SYSDATE depend on session parameters (like NLS_DATEFORMAT or something alike)?

TIA
Bye
Nicola
Re: Sysdate [message #40962 is a reply to message #40961] Thu, 14 November 2002 11:13 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
If the data type of your TIMESTAMP column is DATE, then you would always have sysdate down to seconds resolution. If the data type is VARCHAR2, then you would have the string formatted based on the NLS date format.
Re: Sysdate [message #40975 is a reply to message #40961] Fri, 15 November 2002 03:29 Go to previous messageGo to next message
F. Tollenaar
Messages: 64
Registered: November 2002
Member
You say timestamp is a date field.
That means, (unless you insert trunc(sysdate)) that timestamp contains dates + times.

It's the way you select them that makes it appear like there is no time-component:

SQL> create table table_log (timestamp date);

Table created.

SQL> insert into table_log values (sysdate);

1 row created.

SQL> commit;

Commit complete.

SQL> select * from table_log;

TIMESTAMP
---------
15-NOV-02

SQL> select to_char(timestamp, 'dd-mon-yyyy hh24:mi:ss') from table_log;

TO_CHAR(TIMESTAMP,'D
--------------------
15-nov-2002 11:03:04

SQL> alter session set nls_date_format = 'dd-mon-yyyy hh24:mi:ss'
  2  /

Session altered.

SQL> select * from table_log;

TIMESTAMP
--------------------
15-nov-2002 11:03:04


hth
Frank
Re: Sysdate [message #40981 is a reply to message #40975] Fri, 15 November 2002 04:34 Go to previous messageGo to next message
Nicola
Messages: 14
Registered: March 2002
Junior Member
Yes you're right!
I was seeing the data with a copy of "Free Toad" that don't show always the time portion of a DATE field.
I don't know the reason of this behaviour (some record have the time, some don't).
Seeing the data with sqlplus show the full date+time info. (This copy of toad, btw, don't show even a ROWID field)
Thank you very much (both of you)
Re: Sysdate [message #40984 is a reply to message #40981] Fri, 15 November 2002 04:53 Go to previous message
F. Tollenaar
Messages: 64
Registered: November 2002
Member
The fact that some records do show times and others do not is because TOAD default uses a proportional font.
(In a proportional font the letter w uses more space than the letter i)
This causes some dates to be too big to display.
Try enlarging the date-column in TOAD, and you'll see all time-components

regards,
Frank
Previous Topic: Sequence
Next Topic: Pls help me with a query ...
Goto Forum:
  


Current Time: Mon May 06 18:07:11 CDT 2024