DATEPART/de

From SQLZOO
< DATEPART
Revision as of 17:57, 21 October 2012 by Peter (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Kompatibilität
DATEPART(YEAR, d)
DBMSOKAlternative
IngresNein EXTRACT(YEAR FROM d)
MySQLNein EXTRACT(YEAR FROM d)
OracleNein EXTRACT(YEAR FROM d)
PostgreSQLNein EXTRACT(YEAR FROM d)
SQL ServerJaDATEPART(YEAR, d)

DATEPART

Mit DATEPART werden Teile eines Datumswertes ermittelt.

Es können Jahr (YEAR), Monat (MONTH), Tag (DAY), Stunde (HOUR), Minute (MINUTE) und Sekunde (SECOND) als Teil ermittelt werden.

   DATEPART(YEAR, d)    DATEPART(MONTH, d)
   DATEPART(DAY, d)     DATEPART(HOUR, d)
   DATEPART(MINUTE, d)  DATEPART(SECOND, d) 
schema:gisq

In diesem Beispiel werden Jahr (YEAR) und Monat (MONTH) aus dem whn-Datum ermittelt.

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 gisq.eclipse
SELECT whn
      ,EXTRACT(YEAR FROM td)  AS yr
      ,EXTRACT(MONTH FROM td) AS mnth
  FROM eclipse

Siehe auch

Sprache: English  • Deutsch
Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense