Difference between revisions of "YEAR"

From SQLZOO
Jump to: navigation, search
 
Line 46: Line 46:
 
   <li>[[MONTH |MONTH function]]</li>
 
   <li>[[MONTH |MONTH function]]</li>
 
</ul>
 
</ul>
 +
 +
{{Languages}}

Latest revision as of 21:38, 21 October 2012

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: English  • Deutsch
Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense