DATEPART/de

From SQLZoo
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

Language:Project:Language policy [[:{{#invoke:String|sub|DATEPART/de
 |1
 |Expression error: Unrecognised punctuation character "{".
}}|English]]
DataWars, Data Science Practice Projects - LogoDataWars: Practice Data Science/Analysis with +100 Real Life Projects
  • Your server today is: Dipsy