Revision as of 11:17, 13 July 2012 by Connor
|ingres||No||EXTRACT EXTRACT(YEAR FROM d)|
|mysql||No||EXTRACT(YEAR FROM d)|
|oracle||No||EXTRACT(YEAR FROM d)|
|postgres||No||EXTRACT(YEAR FROM d)|
DATEPART allows you to retrieve components of a date.
You can extract also YEAR, MONTH, DAY, HOUR, MINUTE, SECOND.
DATEPART(YEAR, d) DATEPART(MONTH, d) DATEPART(DAY, d) DATEPART(HOUR, d) DATEPART(MINUTE, d) DATEPART(SECOND, d)
In this example you get the year and the month from the date
SELECT whn ,DATEPART(YEAR, whn) AS yr ,DATEPART(MONTH, whn) AS mnth FROM eclipse
SELECT whn ,EXTRACT(YEAR FROM td) AS yr ,EXTRACT(MONTH FROM td) AS mnth FROM eclipse