Avatar of pothios
pothios asked on

time stamp

hello, how do i insert a time stamp in oracle?
DatabasesEnterprise SoftwareSQL

Avatar of undefined
Last Comment
Mark Wills

8/22/2022 - Mon
SOLUTION
Nerdwood

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER CERTIFIED SOLUTION
Mark Wills

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
pothios

ok im using


insert into record values(1, 'hi', 5, LOCALTIMESTAMP);

how can i actually check the difference between current time and the timestamp that has been stored?
Mark Wills

Did you have a look at that link ? it does talk about localtimestamp, current_timestamp, systimestamp etc etc...

CREATE TABLE ts_test (
x TIMESTAMP,
y TIMESTAMP(0),
z TIMESTAMP(9));

desc ts_test

INSERT INTO ts_test
(x, y, z)
VALUES
(timestamp'2007-08-08 09:00:00.123456789',
timestamp'2007-08-08 09:00:00.123456789',
timestamp'2007-08-08 09:00:00.123456789');

set linesize 121
col x format a30
col y format a21
col z format a31

SELECT * FROM ts_test;

INSERT INTO ts_test
(x, y, z)
VALUES
(localtimestamp, localtimestamp, localtimestamp);

SELECT * FROM ts_test;

INSERT INTO ts_test
(x, y, z)
VALUES
(localtimestamp, localtimestamp, localtimestamp);

SELECT * FROM ts_test;


SELECT VSIZE(x), VSIZE(y), VSIZE(z)
FROM ts_test;


SELECT TO_CHAR(CURRENT_DATE, 'dd-mon-yyyy hh24:mi:ss'),
TO_CHAR(sysdate, 'dd-mon-yyyy hh24:mi:ss')
FROM dual;
Mark Wills

Also, check the examples for date / time functions at :http://www.psoug.org/reference/date_func.html
Your help has saved me hundreds of hours of internet surfing.
fblack61