How-to: EXTRACT

Convert a numeric or date expression to a character String.

Syntax
      EXTRACT (type FROM datetime | interval)

Key
Types that can be extracted:
  YEAR
  MONTH
  DAY
  HOUR
  MINUTE
  SECOND
  TIMEZONE_HOUR
  TIMEZONE_MINUTE
  TIMEZONE_REGION
  TIMEZONE_ABBR

Examples

SQL> SELECT EXTRACT(YEAR FROM DATE '2009-01-04') FROM dual;

SQL> Select expiry_date,
Extract(YEAR from expiry_date) YR,
Extract(month from expiry_date) MTH
From dba_users
Where expiry_date is not null; SQL> select to_char(sysdate,'HH24:MI:SS') "Time Now" from dual; '14:35:56'

“Wall Street and the City Spivs, together with their sycophantic friends in the media, are all part of a big club, and you ain't in it” ~ George Carlin

Related

Oracle SQL Functions
TO_DATE - Convert to a date
TO_NUMBER - Convert to numeric format
CONVERT - Convert a string from one character set to another.
ORA-00932 inconsistent datatypes


 
Copyright © 1999-2024 SS64.com
Some rights reserved