Friday, January 11, 2013

Sysdate function


In Oracle/PLSQL, the sysdate function returns the current system date and time on your local database.

Syntax

The syntax for the sysdate function is:
sysdate

Applies To

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

Example #1

select sysdate
into v_date
from dual;
The variable called v_date will now contain the current date and time value.

Example #2

You could also use the sysdate function in any SQL statement. For example:
select supplier_id, sysdate
from suppliers
where supplier_id > 5000;

Example #3

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;