-
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.
-
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')
-
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.
-
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;
-
If you are under FORM environment, please use "datetime" datatype, that will solve the problem.
HTH
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|