YEAR

From SQLZOO
Revision as of 13:11, 16 July 2012 by Connor (Talk | contribs)

Jump to: navigation, search
Compatibility
YEAR(d)
EngineOKAlternative
ingresYesEXTRACT(YEAR from d)
mysqlYesEXTRACT(YEAR from d)
oracleNoTO_CHAR(d,'YYYY')
postgresNoEXTRACT(YEAR from d)
sqlserverYesDATEPART(YEAR,d)

YEAR

YEAR allows you to retrieve the year from a date.

   YEAR(d)

In this example you get the year from the date field whn.

SELECT EXTRACT(YEAR FROM whn) AS v
      ,whn
      ,wht
  FROM eclipse
SELECT TO_CHAR(whn,'YEAR') AS v
      ,whn
      ,wht
  FROM gisq.eclipse
SELECT YEAR(whn) AS v, whn, wht
  FROM eclipse

See also

Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense