After executing this SQL in oracle 10g:
SELECT SYSDATE, CURRENT_TIMESTAMP FROM DUAL
I receive this strange output:
What is cause of the difference in time? The server time is equal of SYSDATE value
After executing this SQL in oracle 10g:
SELECT SYSDATE, CURRENT_TIMESTAMP FROM DUAL
I receive this strange output:
What is cause of the difference in time? The server time is equal of SYSDATE value
SYSDATE
provides date and time of a server.CURRENT_DATE
provides date and time of client.(i.e., your system)CURRENT_TIMESTAMP
provides data and timestamp of a clinet.SYSDATE
,systimestamp
return datetime of server where database is installed.SYSDATE
- returns only date, i.e., "yyyy-mm-dd".systimestamp
returns date with time and zone, i.e., "yyyy-mm-dd hh:mm:ss:ms timezone"now()
returns datetime at the time statement execution, i.e., "yyyy-mm-dd hh:mm:ss"CURRENT_DATE
- "yyyy-mm-dd",CURRENT_TIME
- "hh:mm:ss",CURRENT_TIMESTAMP
- "yyyy-mm-dd hh:mm:ss timezone". These are related to a record insertion time.SYSDATE
,SYSTIMESTAMP
returns the Database's date and timestamp, whereascurrent_date
,current_timestamp
returns the date and timestamp of the location from where you work.For eg. working from India, I access a database located in Paris. at 4:00PM IST:
select sysdate,systimestamp from dual;
This returns me the date and Time of Paris:
select current_date,current_timestamp from dual;
This returns me the date and Time of India:
Please note the 3:30 time difference.
Note: SYSDATE - returns only date, i.e., "yyyy-mm-dd" is not correct. SYSDATE returns the system date of the database server including hours, minutes, and seconds. For example:
SELECT SYSDATE FROM DUAL; will return output similar to the following: 12/15/2017 12:42:39 PM
CURRENT_DATE
andCURRENT_TIMESTAMP
return the current date and time in the session time zone.SYSDATE
andSYSTIMESTAMP
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*
andCURRENT_*
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.
SYSDATE returns the system date, of the system on which the database resides
CURRENT_TIMESTAMP returns the current date and time in the session time zone, in a value of datatype TIMESTAMP WITH TIME ZONE
execute this comman
and it will provide you the same result.