See Also Example
Returns a Variant containing the number of time intervals between two specified dates.
DateDiff( interval, date1, date2 )
The DateDiff function uses the following parts:
interval String expression that is the interval of time you use to calculate the difference between date1 and date2.
date1, date2 Two dates you want to use in the calculation.
You can use the DateDiff function to determine how many specified time intervals exist between two dates. For example, you might use DateDiff to calculate the number of days between two dates or the number of weeks between today and the end of the year.
The following table lists the valid time periods and their interval values. These intervals are also used by the Format function.
Time period Interval
Day of Year y
If you want to know the number of days between date1 and date2, you can use either Day of Year or Day ("y" or "d").
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 date1 but not date2. 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 date1 if it falls on a Sunday; but it doesn't count date2, 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.
Distribution Note When you create and distribute applications that use this function in your code, you should install the file MSAFINX.DLL in the customer's Microsoft Windows \SYSTEM directory. The Visual Basic Setup Kit provides tools to help you write setup programs that install your applications.