PL/SQL CURRENT_DATE

Oracle PL/SQL is a powerful procedural language that enables developers to create sophisticated database applications. One of the essential functions in Oracle PL/SQL is the CURRENT_DATE function, which returns the current date and time.

The CURRENT_DATE function is part of the built-in Date and Time functions in Oracle PL/SQL. It is used to obtain the current system date and time in the default format of “DD-MON-YY HH24:MI:SS.”

Syntax

Here is the syntax for using the CURRENT_DATE function:

SELECT CURRENT_DATE FROM dual;

The “dual” keyword is required in Oracle SQL when you want to select a value that is not stored in a table. It is a special one-row, one-column table that is used to perform calculations or return a single value.

When you run this query, the CURRENT_DATE function will return the current date and time in the default format.

Example

For example, if you run this query on April 8th, 2023 at 3:15 PM, the result will be:

08-APR-23 15:15:00

The CURRENT_DATE function is useful in many scenarios, such as calculating the difference between two dates, filtering data based on a specific date range, or generating reports based on the current date.

In conclusion, the CURRENT_DATE function in Oracle PL/SQL is a powerful tool that helps developers work with dates and times in their applications. It is easy to use and provides accurate results, making it an essential function for any database developer.