In Oracle/SQL CURRENT DATE is returned by Oracle CURRENT_DATE Function. Also, SQL CURRENT_DATE Function returns time of current SQL session.Oracle CURRENT_DATE Function returns date/time set by SQL ALTER SESSION Statement. Oracle CURRENT DATE can also be used with SQL TRUNC Function to view only the date component.
SQL CURRENT DATE Function Syntax
SELECT CURRENT_DATE FROM table_name;
SQL CURRENT DATE Examples
Oracle CURRENT DATE – Using SELECT Statement Example
Oracle CURRENT_DATE Function is used with SQL SELECT Statement to fetch current date/time information.
For example, below SQL query returns current date/time.
SELECT CURRENT_DATE FROM DUAL;
Above SQL query may return something like “11/5/2012 11:52:27 AM”.
Oracle CURRENT DATE – SET TIME ZONE Example
The ALTER SESSION SET TIME ZONE Statement alters the time zone of the database.
For example, below SQL ALTER SESSION SET TIME ZONE Statement will alter the time zone of database.
ALTER SESSION SET TIME_ZONE = '-7:0';
The SQL query below will return different data now.
SELECT CURRENT_DATE FROM DUAL;
Above SQL CURRENT_DATE query may return something like “11/4/2012 11:24:22 PM” because time zone has been altered.
Oracle CURRENT DATE – Removing Time Component Example
SQL TRUNC Function can be used with the SQL CURRENT_DATE to remove the time component.
For example, the SQL query below will return current date and not time.
SELECT TRUNC(CURRENT_DATE) FROM dual;
Above SQL query may return “11/4/2012”.