Skip to main content

DATEDIFF() Function

Definition The DATEDIFF() function returns the difference between two dates.   Syntax DATEDIFF(interval, date1, date2) where interval is required and it is the part of return.  This can be one of the

Updated over 2 weeks ago

Definition

The DATEDIFF() function returns the difference between two dates.

Syntax

DATEDIFF(interval, date1, date2)

where interval is required and it is the part of return. This can be one of the following values:

  • year, yyyy, yy = Year

  • quarter, qq, q = Quarter

  • month, mm, m = month

  • dayofyear, dy, y = Day of the year

  • day, dd, d = Day of the month

  • week, ww, wk = Week

  • weekday, dw, w = Weekday

  • hour, hh = hour

  • minute, mi, n = Minute

  • second, ss, s = Second

  • millisecond, ms = Millisecond

And date1 and date2 are required and are the two dates to calculate the difference between.

Example(s)

See how DATEDIFF can be used to:

Did this answer your question?