Funzione DATE_DIFF in Amazon QLDB - Database Amazon Quantum Ledger (Amazon QLDB)

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

Funzione DATE_DIFF in Amazon QLDB

In Amazon QLDB, utilizza laDATE_DIFF funzione per restituire la differenza tra le parti di data specificate di due determinati timestamp.

Sintassi

DATE_DIFF( datetimepart, timestamp1, timestamp2 )

Argomenti

parte data/ora

Parte relativa a data o ora su cui viene eseguita la funzione. Questo parametro può essere uno dei seguenti:

  • year

  • month

  • day

  • hour

  • minute

  • second

timestamp1, timestamp2

I due nomi di campo o espressioni del tipo di datitimestamp che la funzione confronta. Se timestamp2 è successivo a timestamp1, il risultato è positivo. Se timestamp2 è precedente a timestamp1, il risultato è negativo.

Un valore letterale del timestamp di Ion può essere indicato con backticks (`...`). Per dettagli sulla formattazione ed esempi di valori di timestamp, consulta Timestamp nel documento con le specifiche di Amazon Ion.

Tipo restituito

int

Esempi

DATE_DIFF(year, `2010-01-01T`, `2011-01-01T`) -- 1 DATE_DIFF(year, `2010-12T`, `2011-01T`) -- 0 (must be at least 12 months apart to evaluate as a 1 year difference) DATE_DIFF(month, `2010T`, `2010-05T`) -- 4 (2010T is equivalent to 2010-01-01T00:00:00.000Z) DATE_DIFF(month, `2010T`, `2011T`) -- 12 DATE_DIFF(month, `2011T`, `2010T`) -- -12 DATE_DIFF(month, `2010-12-31T`, `2011-01-01T`) -- 0 (must be at least a full month apart to evaluate as a 1 month difference) DATE_DIFF(day, `2010-01-01T23:00Z`, `2010-01-02T01:00Z`) -- 0 (must be at least 24 hours apart to evaluate as a 1 day difference) -- Runnable statements SELECT DATE_DIFF(year, `2010-01-01T`, `2011-01-01T`) FROM << 0 >> -- 1 SELECT DATE_DIFF(month, `2010T`, `2010-05T`) FROM << 0 >> -- 4

Funzioni correlati correlati correlati