How to Get Current Date in PL/SQL?

  • PLSQL
  • 1 min read

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: