Tuesday, August 18, 2009

Getting Current Time on DB

To verify a bugs I had a need to get the current time on the Database
Server. Here are some SQL which might be useful.

Note: This is on Oracle DB

To get the server Date:

SELECT sysdate FROM dual;

This will give you the system date in this format, Ex: 18-AUG-09

To get the server TimeZone:

SELECT sessiontimezone FROM dual;

This will give you the system timezone in this format, Ex: Asia/Calcutta

To get the server time:

SELECT systimestamp FROM dual;

This will give you the system time in this format,
Ex: 18-AUG-09 04.49.43.648480000 AM -07:00

1 comment:

Kevin said...

I work on a mainframe and constantly need to validate batch output data into temp tables. The data is financial related so the logical day of the db impacts the calculations so thanks for this.