DATEDIFF

Description

Returns the number of time intervals between two specified dates.

Syntax

DATEDIFF ( interval, date1, date2 )

Parameter Description
interval String expression that is the interval of time to add. Interval can be one of the following values:
  • yyyy — Year
  • q — Quarter
  • m — Month
  • y — Day of year
  • d — Day
  • w — Weekday
  • ww — Week
  • h — Hour
  • n — Minute
  • s — Second
date1 The first date to use in the calculation.
date2 The second date to use in the calculation.

Remarks

DATEDIFF can be used to calculate the number of days between two dates, or the number of weeks between today and the end of the year. When interval is Weekday ("w"), DATEDIFF returns the number of weeks between the two dates. If date1 falls on a Monday, DATEDIFF counts the number of Mondays until date2. It counts date2 but not date1. If interval is Week ("ww"), however, the DATEDIFF function returns the number of calendar weeks between the two dates. It counts the number of Sundays between date1 and date2. DATEDIFF counts date2 if it falls on a Sunday; but it doesn't count date1, even if it does fall on a Sunday.

If date1 refers to a later point in time than date2, the DATEDIFF function returns a negative number. When comparing December 31 to January 1 of the immediately succeeding year, DATEDIFF for Year ("yyyy") returns 1 even though only a day has elapsed.