Difference between revisions of "YEAR"

From SQLZOO
Jump to: navigation, search
(Created page with "<table align='right' border='1'> <caption>Compatibility</caption> <tr><th colspan='3'>YEAR(d)</th></tr> <tr><td align='center'>'''Engine'''</td><td align='center'>'''OK'''</td...")
 
Line 28: Line 28:
 
       ,whn
 
       ,whn
 
       ,wht
 
       ,wht
   FROM eclipse
+
   FROM gisq.eclipse
 
</source>
 
</source>
 
<source lang='sql' class='def'>
 
<source lang='sql' class='def'>

Revision as of 13:11, 16 July 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

Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense