How to Get Current Date in PL/SQL?

The following are the examples to get the current date in PL/SQL.

Examples To Get The Current Date in PL/SQL

1. Using Sysdate Function

SET SERVEROUTPUT ON;

DECLARE
d_current_date DATE;
BEGIN
d_current_date := SYSDATE;
DBMS_OUTPUT.put_line ('The Date today is: ' || d_current_date);
END;
/

Output:

The Date today is: 19-AUG-18
PL/SQL procedure successfully completed.

2. Using CURRENT_DATE Function

SET SERVEROUTPUT ON;

DECLARE
d_current_date DATE;
BEGIN
d_current_date := CURRENT_DATE;
DBMS_OUTPUT.put_line ('The Date today is: ' || d_current_date);
END;
/

Output:

The Date today is: 19-AUG-18
PL/SQL procedure successfully completed.

3. Get Current Date with Time Using To_Char() Function

SET SERVEROUTPUT ON;

DECLARE
d_current_date DATE;
BEGIN
d_current_date := CURRENT_DATE;
DBMS_OUTPUT.put_line ('The Date today is: ' || to_char(d_current_date, 'DD/MM/YYYY HH24:MI:SS'));
END;
/

Output:

The Date today is: 19/08/2018 16:54:52
PL/SQL procedure successfully completed.

See also:

Vinish Kapoor
Vinish Kapoor

Vinish Kapoor is a seasoned software development professional and a fervent enthusiast of artificial intelligence (AI). His impressive career spans over 20 years, marked by a relentless pursuit of innovation and excellence in the field of information technology. As an Oracle ACE, Vinish has distinguished himself as a leading expert in Oracle technologies, a title awarded to individuals who have demonstrated their deep commitment, leadership, and expertise in the Oracle community.