Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different CURRENT_TIMESTAMP and SYSDATE in oracle

After executing this SQL in oracle 10g:

SELECT SYSDATE, CURRENT_TIMESTAMP  FROM DUAL 

I receive this strange output: Toad output for query

What is cause of the difference in time? The server time is equal of SYSDATE value

like image 897
Mohsen Kashi Avatar asked Jul 29 '13 10:07

Mohsen Kashi


People also ask

What is the difference between current date and Sysdate in Oracle?

SYSDATE will give the system date of the server. CURRENT_DATE will give you the system date of the session. For example, if your oracle server is in UK, the SYSDATE will be the UK time whereas, the CURRENT_DATE will be the Indian time.

What is the difference between CURRENT_TIMESTAMP and Getdate?

CURRENT_TIMESTAMP is an ANSI SQL function whereas GETDATE is the T-SQL version of that same function. One interesting thing to note however, is that CURRENT_TIMESTAMP is converted to GETDATE() when creating the object within SSMS. Both functions retrieve their value from the operating system in the same way.

What is the difference between Sysdate and Systimestamp?

SYSDATE: Show the date and time of the database server. CURRENT_DATE: Show the date and time of the session timezone. SYSTIMESTAMP: Shows the date and time of the database server, in a TIMESTAMP WITH TIME ZONE data type.

What is the difference between Systimestamp and CURRENT_TIMESTAMP?

SYSTIMESTAMP returns current timestamp on database server, while current_timestamp returns current timestamp on client machine. So if your database server is in New York and client box is in California, SYSTIMESTAMP will be 3 hours ahead of CURRENT_TIMESTAMP.


1 Answers

CURRENT_DATE and CURRENT_TIMESTAMP return the current date and time in the session time zone.

SYSDATE and SYSTIMESTAMP return the system date and time - that is, of the system on which the database resides.

If your client session isn't in the same timezone as the server the database is on (or says it isn't anyway, via your NLS settings), mixing the SYS* and CURRENT_* functions will return different values. They are all correct, they just represent different things. It looks like your server is (or thinks it is) in a +4:00 timezone, while your client session is in a +4:30 timezone.

You might also see small differences in the time if the clocks aren't synchronised, which doesn't seem to be an issue here.

like image 53
Alex Poole Avatar answered Sep 20 '22 19:09

Alex Poole