Returns a Variant (Long) specifying the number of time intervals between two dates.
Syntax DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]]) Key interval The interval of time to add. date1, date2 The two dates to compare Variant (Date). firstdayofweek A constant (0-7)that specifies the first day of the week. default=vbSunday (1). firstweekofyear A constant (0-3) that specifies the first week of the year. default = the week in which January 1 occurs (1).
|y||Day of year|
0 vbUseSystem - Use the NLS API setting.
1 vbFirstJan1 - Start with week in which January 1 occurs (default).
2 vbFirstFourDays - Start with the first week that has at least four days in the new year.
3 vbFirstFullWeek - Start with first full week of the year.
If date1 refers to a later point in time than date2, then DateDiff() returns a negative number.
The firstdayofweek argument will affect calculations that use week intervals.
When comparing December 31 to January 1, DateDiff for Year ("yyyy") returns 1 even though only a day has elapsed.
The DateDiff() function can be used in VBA or in an SQL query.
DateDiff("ww", "Jan 01","Feb 14")
DateDiff("d", dtmStart, dtmEnd)
“Beauty is Nature's coin, must not be hoarded, but must be current” ~ John Milton
Date - Return the current date.
DateAdd - Add a time interval to a date.
DatePart - Return part of a given date.
DateSerial - Return a date given a year, month, and day.