DBAsupport.com Forums - Powered by vBulletin
Results 1 to 6 of 6

Thread: Current Time

  1. #1
    Join Date
    Apr 2001
    Posts
    13
    I need to populate a field with the current time. All the sysdate functions i could find do the date AND time. Any help would be appreciated.

    Thanks in advance,
    Khurram.

  2. #2
    Join Date
    Jul 2000
    Posts
    296
    What is the datatype of the field?
    If it is DATE, use SYSDATE.
    If it is VARCHAR2, use SYSDATE with TO_CHAR function:
    TO_CHAR(SYSDATE, 'HH24:MI:SS')

  3. #3
    Join Date
    Apr 2001
    Posts
    13
    Thanks akkerend. But the thing is that the datatype is DATE and I am using SYSDATE. The feild is being populated by just the date.

  4. #4
    Join Date
    Jul 2000
    Posts
    296
    DATE dataype stores date (century, year, month and day) and time (hour, minute and second) information. The function SYSDATE returns a DATE.

    How do you insert sysdate?
    Try something like:
    INSERT INTO your_table(primary_key_column, date_column)
    VALUES(primary_key_value, SYSDATE);

    To select the field, use TO_CHAR function with date format:
    SELECT TO_CHAR(date_column, 'DD-MON-YYYY HH24:MI:SS')
    FROM your_table;




  5. #5
    Join Date
    Oct 2000
    Posts
    123
    If you are under FORM environment, please use "datetime" datatype, that will solve the problem.

    HTH

  6. #6
    Join Date
    Mar 2001
    Posts
    5

    Arrow check this solution

    Hello,
    If you want a column to accept both time and date.
    you first change the session to accept both time and date by
    ALTER SESSION SET NLS_DATE_FORMAT='DD-MON-YY HH24:MI:SS';

    then insert into the table by
    INSERT INTO TABLE VALUES(TO_CHAR(SYSDATE,'DD-MON-YY HH24:MI:SS'));

    bye
    shaju

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width