Extract Function in Oracle
The extract function extracts a value from a date. You can only extract YEAR, MONTH, and DAY from a DATE
Syntax:
EXTRACT (
{ YEAR
MONTH
DAY
HOUR
MINUTE
SECOND }
{ TIMEZONE_HOUR
TIMEZONE_MINUTE }
{ TIMEZONE_REGION
TIMEZONE_ABBR }
FROM { date_value
interval_value } )
• Works in - Oracle 11g, Oracle 10g, Oracle 9i
Sample:
select extract(YEAR FROM sysdate) from dual;
EXTRACT(YEARFROMSYSDATE)
------------------------
2013
1 row selected.
select extract(MONTH FROM sysdate) from dual;
EXTRACT(MONTHFROMSYSDATE)
-------------------------
5
1 row selected.
select extract(DAY FROM sysdate) from dual;
EXTRACT(DAYFROMSYSDATE)
-----------------------
14
1 row selected.
0 comments:
Post a Comment