SQL Notebook (logo)

DATEDIFF Function

Returns the number of calendar or clock boundaries crossed between two dates. A calendar boundary is a transition from one day to the next, from one month to the next, etc. A clock boundary is a transition from one hour of the day to the next, one minute of the day to the next, etc.

Syntax

DATEDIFF(date-part, start-date, end-date)

Arguments

Return Value

An integer representing the number of the specified date-part boundaries that are crossed between start-date and end-date.

Examples