CoderZone.org

Category: >> Oracle PL/SQL >> TIMESTAMP: EXTRACT Bookmark and Share

<< lastnext >>

Snippet Name: TIMESTAMP: EXTRACT

Description: Returns the value of a specified datetime field from a datetime or interval value expression.

Also see:
» FUNCTIONS: date/time
» TIMESTAMP: TZ_OFFSET
» TIMESTAMP: TRUNC
» TIMESTAMP: SysTimeStamp
» TIMESTAMP: SYS_EXTRACT_UTC
» TIMESTAMP: SessionTimeZone
» TIMESTAMP: LocalTimestamp
» TIMESTAMP: FROM_TZ
» TIMESTAMP: DUMP
» TIMESTAMP: DBTIMEZONE
» TIMESTAMP: Get current timestamp
» TIMESTAMP: List time zones

Comment: (none)

Author: CoderZone
Language: PL/SQL
Highlight Mode: PLSQL
Last Modified: March 04th, 2009

EXTRACT (
{ YEAR | MONTH | DAY | HOUR | MINUTE | SECOND }
| { TIMEZONE_HOUR | TIMEZONE_MINUTE }
| { TIMEZONE_REGION | TIMEZONE_ABBR }
FROM { date_value | interval_value } )
 
VALUES that can be extracted:
 
YEAR
MONTH
DAY
HOUR
MINUTE
SECOND
TIMEZONE_HOUR
TIMEZONE_MINUTE
TIMEZONE_REGION
TIMEZONE_ABBR
 
-- You can only extract YEAR, MONTH, and DAY from a DATE.
-- You can only extract TIMEZONE_HOUR and TIMEZONE_MINUTE 
-- from a timestamp with a time zone datatype.
 
EXTRACT (<type> FROM <datetime | interval>)
SELECT EXTRACT(YEAR FROM DATE '2007-04-01') FROM dual;
 
xtract(YEAR FROM DATE '2003-08-22')      -- would return 2003
EXTRACT(MONTH FROM DATE '2003-08-22')   -- would return 8
EXTRACT(DAY FROM DATE '2003-08-22')      -- would return 22
 
 
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© coderzone.org | users online: 11