Back to the time interval between two dates.
DateDiff (interval, date1, date2 [, firstdayofweek] [, firstweekofyear]])
DateDiff function syntax has the following parameters:
interval Required. String expression that is used to calculate the time between date1 and date2 interval. The values, see "Settings" section.
date1, date2 Required. Date of expression. Used to calculate the two dates.
firstdayofweek optional. The first day of the week specified constant. If not specified, the default is Sunday. The values, see "Settings" section.
firstweekofyear optional. The first week of the year specified constant. If not specified, the default location for the January 1st week. The values, see "Settings" section.
interval parameter can have the following values:
y number of days a year
w the number of days a week
h-hour ("I have not succeeded with this before, do not know how it is, minute, hour, can not, hope there is to know the friends to help, thank you")
n minutes ("Now a lot of articles online is actually more minutes with m, the right should be n, a small New hereby amended")
firstdayofweek parameter can have the following values:
vbUseSystem 0 using regional language support (NLS) API set.
vbSunday 1 Sunday (default)
vbMonday 2 Monday
vbTuesday 3 Tuesday
vbWednesday 4 Wednesday
vbThursday 5 Thursday
vbFriday 6 Friday
vbSaturday 7 Saturday
firstweekofyear parameter can have the following values:
use of regional language support vbUseSystem 0 (NLS) API set.
vbFirstJan1 1 by the Jan. 1 week where the (default).
vbFirstFourDays 2 by the New Year at least four days in the first week.
vbFirstFullWeek 3 in the new year by the first full week.
DateDiff function is used to determine between the two dates specified number of time intervals. For example, you can use the DateDiff calculation of the number of days difference between two dates, or the day of the year the number of weeks between the last day.
To calculate the difference between date1 and date2 number of days, you can use "the number of days a year" ("y") or "Day" ("d"). When the interval is "the number of days a week" ("w") when, DateDiff returns the number of weeks between two dates. If date1 is Monday, the Monday before date2 DateDiff to calculate the number. This result contains does not contain date2 date1. If the interval is the "Week" ("ww"), the DateDiff function returns the calendar in the number of weeks between two dates. Between date1 and date2 function calculates the number of Sundays. If date2 is Sunday, DateDiff to calculate date2, but even if date1 is Sunday, it will not count date1.
If date1 is later than date2, the DateDiff function returns a negative number.
firstdayofweek parameters will use the "w" and "ww" interval symbols affect the calculation.
If date1 or date2 is a date of writing, is designated the year will be the date of the fixed part. However, if date1 or date2 is included in the quotation marks ("") and omitted in the year, calculated in the code each time date1 or date2 expression, it will insert the current year. This can be written for different years of the program code.
In the interval as the "year" ("yyyy"), the comparison on December 31 and January 1 next year, although in practice only a difference of one day, DateDiff returns 1 indicates a difference of one year.