Quotezurück (hier als Beispiel DATEDIFF von MySQL/MariaDB mit Einheit "Tag") obwohl zwischen den Daten nur eine Stunde liegt.1
SELECT DATEDIFF( '2015-01-02 00:00:00', '2015-01-01 23:00:00' )
QuoteDATEDIFF() returns (expr1 – expr2) expressed as a value in days from one date to the other. expr1 and expr2 are date or date-and-time expressions. Only the date parts of the values are used in the calculation.
DATEDIFF(SECOND, timestamp '2015-09-30 00:00:00.999', timestamp '2015-09-30 00:00:01.000')
SECOND(TIMEDIFF('2015-09-30 00:00:01.000', '2015-09-30 00:00:00.999'))
1
2
SELECT MICROSECOND(TIMEDIFF('2015-09-30 00:00:01.000', '2015-09-30 00:00:00.999'));
1.000
QuoteInteressante Frage auch: Differenz in Monaten. Was die Frage aufwirft, wieviele Tage ein Monat hat. Da sehen wir schon, diese Frage ist Blödsinn weil...
Und wieviele Tage hat ein Jahr? Auch Blödsinn die Frage weil: Siehe oben.
1
2
3
import pandas as pd
drei_monate_spaeter = pd.Period("2022-01", freq="M") + 3
assert drei_monate_spaeter == pd.Period("2022-04", freq="M")