YEAR

From SQLZoo
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

Language:Project:Language policy English  • Deutsch
DataWars, Data Science Practice Projects - LogoDataWars: Practice Data Science/Analysis with +100 Real Life Projects
  • Your server today is: digitalocean-sqlzoo