EXTRACT/de

From SQLZOO
Jump to: navigation, search
Kompatibilität
EXTRACT(YEAR FROM d)
DBMSOKAlternative
IngresJa
MySQLJa YEAR(d)
OracleJa TO_CHAR(d,'YYYY')
PostgreSQLJa YEAR(d)
SQL ServerNein 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

Sprache: English  • Deutsch
Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense