date_diff
Count the unit boundaries crossed between two dates or timestamps. For example, January 31 to February 1 crosses one month boundary.
Try an expression
In Formula, enter the expression and set Output type to BIGINT.
Expression
date_diff('hour', TIMESTAMP '1992-09-30 23:59:59', TIMESTAMP '1992-10-01 01:58:00')Result
2To use your own data, replace the example values with column names. Keep format strings and other options as written.
Arguments and types
date_diff(part, startdate, enddate)- part
- Text
- startdate
- Date, Time, Timestamp
- enddate
- Date, Time, Timestamp
Supported signatures (4)
date_diff(part: VARCHAR, startdate: DATE, enddate: DATE) → BIGINT
date_diff(part: VARCHAR, startdate: TIME, enddate: TIME) → BIGINT
date_diff(part: VARCHAR, startdate: TIMESTAMP WITH TIME ZONE, enddate: TIMESTAMP WITH TIME ZONE) → BIGINT
date_diff(part: VARCHAR, startdate: TIMESTAMP, enddate: TIMESTAMP) → BIGINTThe result type can depend on the input types. See DuckDB for the full argument rules.
Things to know
Use this in a date difference formula, such as the days between two dates. Other tools often call it datediff.
If the first argument is missing, the result is NULL.
Function metadata from DuckDB, used under the MIT license.