EXTRACT/de
From SQLZoo
EXTRACT(YEAR FROM d) | ||
---|---|---|
DBMS | OK | Alternative |
Ingres | Ja | |
MySQL | Ja | YEAR(d) |
Oracle | Ja | TO_CHAR(d,'YYYY') |
PostgreSQL | Ja | YEAR(d) |
SQL Server | Nein | DATEPART(YEAR, d) |
EXTRACT
EXTRACT ermittelt Bestandteile eines Datumswertes.
Folgende Werte können ermittelt werden: Jahr (YEAR), Monat (MONTH), Tag (DAY), Stunde (HOUR), Minute (MINUTE), Sekunde (SECOND).
EXTRACT(YEAR FROM d) EXTRACT(MONTH FROM d) EXTRACT(DAY FROM d) EXTRACT(HOUR FROM d) EXTRACT(MINUTE FROM d) EXTRACT(SECOND FROM d)
In diesem Beispiel werden das Jahr und die Stunde aus dem whn
-Datum ermittelt.
SELECT whn
,DATEPART(YEAR, whn) AS yr
,DATEPART(HOUR, whn) AS hr
FROM eclipse
SELECT whn
,EXTRACT(YEAR FROM td) AS yr
,EXTRACT(HOUR FROM td) AS hr
FROM gisq.eclipse
SELECT whn
,EXTRACT(YEAR FROM td) AS yr
,EXTRACT(HOUR FROM td) AS hr
FROM eclipse
Siehe auch
Language: | [[:{{#invoke:String|sub|EXTRACT/de
|1 |Expression error: Unrecognised punctuation character "{".}}|English]] |
---|