The DateDiff function applies to: MicrosoftOfficeAccess2007 returns the variable type (long type), specifying the time interval between two specified dates. See some example syntax DateDiff (interval, date1, date2 [, firstdayofweek] [, firstweekofyear]). The syntax of the DateDiff function contains the following parameters (Parameter
The DateDiff function is applicable to the variable type (long type) returned by Microsoft Office Access 2007, which specifies the time interval between two specified dates. See some example syntax DateDiff (interval, date1, date2 [, firstdayofweek] [, firstweekofyear]). The syntax of the DateDiff function contains the following parameters (Parameter
DateDiffFunction
Applicable:Microsoft Office Access 2007
Returns the variable type (long type), which specifies the time interval between two specified dates.
See some examples
Syntax
DateDiff (interval, date1, date2 [, firstdayofweek] [, firstweekofyear])
DateDiffFunctionThe syntax includes the following parameters:(Parameters: operation, event, method, attribute,FunctionOr the value of information provided by the process .):
Parameters |
Description |
Interval |
Required. String expression(String expression: Any expression that evaluates to a column of continuous characters. The element of the expression can be: return the string or string Variant (VarType 8)Function; String literal value, constant, variable, or Variant .)This expression is used to calculate the time interval between date1 and date2. |
Date1, date2 |
Required. Variable type (date type ). Two dates to be used for calculation. |
Firstdayofweek |
Optional. Constant(Constant: the value that is not calculated, so it will not change. For example, the number 210 and text "quarterly income" are constants. The values generated by expressions and expressions are not constants .)Specifies the first day of a week. If not specified, the default value is Sunday. |
Firstweekofyear |
Optional. A constant that specifies the first week of a year. If this parameter is not specified, the first week is the week of July 22, January 1 by default. |
Set
Interval parameter(Parameters: operation, event, method, attribute,FunctionOr the value of information provided by the process .)Includes the following settings:
Set |
Description |
Yyyy |
Year |
Q |
Quarter |
M |
Month |
Y |
One day of a year |
D |
Days |
W |
Workday |
Ww |
Week |
H |
Hour |
N |
Minute |
S |
Seconds |
The firstdayofweek parameter includes the following settings:
Constant |
Value |
Description |
VbUseSystem |
0 |
Use nls api settings. |
VbSunday |
1 |
Sunday (default) |
VbMonday |
2 |
Monday |
VbTuesday |
3 |
Tuesday |
VbWednesday |
4 |
Wednesday |
VbThursday |
5 |
Thursday |
VbFriday |
6 |
Friday |
VbSaturday |
7 |
Saturday |
Constant |
Value |
Description |
VbUseSystem |
0 |
Use nls api settings. |
VbFirstJan1 |
1 |
It starts from the week where January 1, January 1 (default ). |
VbFirstFourDays |
2 |
Start from the first week of at least four days of the new year. |
VbFirstFullWeek |
3 |
From the first full week of the year. |
Annotation
You can use DateDiffFunctionDetermines how many specified time intervals exist between two dates. For example, you can use DateDiff to calculate the number of days between two dates or the number of weeks between today and the end of the year.
To calculate the number of days between date1 and date2, you can use "one day of a year" ("y") or "day" ("d "). When interval is "workday" ("w"), DateDiff returns the number of weeks between two dates. If date1 is Monday, DateDiff calculates the number of Monday before date2. Date2 is included, but date1 is not included. However, if interval is "Week" ("ww"), DateDiffFunctionReturns the number of calendar weeks between two dates. It calculates the number of Sundays between date1 and date2. If date2 is Sunday, DateDiff will include it, but it will not be included even if date1 is Sunday.
If date1 references a time point later than date2, then DateDiffFunctionReturns a negative number.
The firstdayofweek parameter affects the calculation of the interval between "w" and "ww.
If date1 or date2 is a date text(Date text: any character sequence with a valid format, which is enclosed by a serial number. Valid formats include the specified date format or common date format set by the Code region .)The specified annual meeting becomes the permanent part of the date. However, if date1 or date2 is enclosed in double quotation marks ("") and the year is omitted, the current year is inserted into the code each time date1 or date2 expressions are calculated. In this way, you can write code for different years.
When we compare January 1, December 31 with January 1, January 1, for "yyyy", DateDiff returns 1 even if only one day is used.
Note: For date1 and date2, if the Calendar attribute is set to the Gregorian Calendar, the provided date must be the Gregorian Calendar. If the calendar is a calendar, the provided date must be a calendar.