TIMEDIFF

functionsupportedCore SQL functions

docs.snowflake.com ↗

Date & time functions

Calculates the difference between two date, time, or timestamp expressions based on the specified date or time part. The function returns the result of subtracting the second argument from the third argument. Alternative for DATEDIFF.

Syntax

TIMEDIFF( <date_or_time_part> , <date_or_time_expr1> , <date_or time_expr2> )

Parameters

NameRequiredDescription
date_or_time_partrequiredThe unit of time. Must be one of the values listed in Supported date and time parts (for example, month). The value can be a string literal or can be unquoted (for example, 'month' or month).
date_or_time_expr1, date_or_time_expr2requiredThe values to compare. Must be a date, a time, a timestamp, or an expression that can be evaluated to a date, a time, or a timestamp. The value date_or_time_expr1 is subtracted from date_or_time_expr2.

Returns

Returns an integer representing the number of units (seconds, days, etc.) difference between date_or_time_expr2 and date_or_time_expr1.

Usage notes

Referenced by