YEAR
From SQLZoo
YEAR(d) | ||
---|---|---|
Engine | OK | Alternative |
ingres | Yes | EXTRACT(YEAR from d) |
mysql | Yes | EXTRACT(YEAR from d) |
oracle | No | TO_CHAR(d,'YYYY') |
postgres | No | EXTRACT(YEAR from d) |
sqlserver | Yes | DATEPART(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
- EXTRACT function
- +(date) function
- HOUR function
- MINUTE function
- DAY function
- SECOND function
- MONTH function
Language: | English • Deutsch |
---|