totn Oracle Functions

Oracle / PLSQL: SYSDATE function

This Oracle tutorial explains how to use the Oracle/PLSQL SYSDATE function with syntax and examples.

Description

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

Syntax

The syntax for the SYSDATE function 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 function can be used in the following versions of Oracle/PLSQL:

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

Example

Let's look at some Oracle SYSDATE function examples and explore how to use the SYSDATE function in Oracle/PLSQL.

For example:

SELECT SYSDATE
INTO v_date
FROM dual;

The variable called v_date will now contain the date and time at the moment the command is executed.

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

For example:

SELECT supplier_id, SYSDATE
FROM suppliers
WHERE supplier_id > 5000;

If you wanted to extract the date portion only (and exclude the time component), you could use the TO_CHAR function.

For example:

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