| |
Learn how to use the Visual Basic DateDiff function
The DateDiff function
returns a long integer specifying the number of time intervals between
two specified dates.
Syntax:
DateDiff(interval, date1, date2[,
firstdayofweek[, firstweekofyear]])
The DateDiff function syntax has these parts:
|
Part |
Description |
|
interval |
Required. String
expression that is the interval of time you use to calculate the difference
between date1 and date2..
The string expression
can be any of the following:
|
Expression |
Description |
|
"yyyy" |
Year |
|
"q" |
Quarter |
|
"m" |
Month |
|
"y" |
Day of year |
|
"d" |
Day |
|
"w" |
Weekday |
|
|
|
|
"h" |
Hour |
|
"n" |
Minute |
|
"s" |
Second |
|
|
date1, date2 |
Required; Date.
The two dates you want to use in the calculation
|
|
firstdayofweek |
Optional. A constant
that specifies the first day of the week. If not specified, Sunday is
assumed.
|
|
firstweekofyear |
Optional. A constant
that specifies the first week of the year. If not specified, the first week
is assumed to be the week in which January 1 occurs.
|
|