Oracle / PLSQL: SYSDATE function

This article is written about how to use the Oracle/PLSQL SYSDATE characteristic with syntax and examples.

Description

The Oracle/PLSQL SYSDATE characteristic returns the current machine date and time on your local database.

Syntax

The syntax for the SYSDATE feature in Oracle/PLSQL is:

SYSDATE

Parameters or Arguments

There are no parameters or arguments for the SYSDATE function.

Returns

The SYSDATE function returns a date value.

Applies To

The SYSDATE characteristic can be used in the following variations of Oracle/PLSQL:

Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i

Example

Let’s appear at some Oracle SYSDATE function examples and discover how to use the SYSDATE feature in Oracle/PLSQL.

For example:

SELECT SYSDATE
INTO v_date
FROM dual;

The variable referred to as v_date will now include the date and time at the second the command is executed.

You should also use the SYSDATE function in any SQL statement.

For example:

SELECT supplier_id, SYSDATE
FROM suppliers
WHERE supplier_id > 5000;

If you desired to extract the date element only (and eliminate the time component), you should use the TO_CHAR function.

For example:

SELECT supplier_id, TO_CHAR(SYSDATE, 'yyyy/mm/dd')
FROM suppliers
WHERE supplier_id > 5000;