Name
DateDiff Function — Microsoft.VisualBasic.DateAndTime
Synopsis
DateDiff(interval, date1, date2
[,dayofweek
[,weekofyear
]])
interval
required; String orDateInterval
enumSpecifies the time unit used to express the difference between
date1
anddate2
date1
,date2
required; Date or a literal dateThe starting and ending dates, whose difference is computed as
date2
-
date1
dayofweek
optional;FirstDayOfWeek
enumA member of the
FirstDayOfWeek
enumweekofyear
optional;FirstWeekOfYear
enumA member of the
FirstWeekOfYear
enum
Return Value
A Long specifying the number of time intervals between the two dates
Description
Calculates the number of time intervals between two dates. For example, you can use the function to determine how many days there are between 1 January 1980 and 31 May 1998.
interval
can be one of the following
literal strings:
|
Year |
|
Quarter |
|
Month |
|
Day of year |
|
Day |
|
Weekday |
|
Week |
|
Hour |
|
Minute |
|
Second |
interval
can also be a member of the
DateInterval
enum:
Enum DateInterval Day DayOfYear Hour Minute Month Quarter Second Week Weekday WeekOfYear End Enum
When interval
is
Weekday
or "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
date2
, but not
date1
. If
interval
is Week
or
"ww"
, however, DateDiff
returns the number of calendar weeks between the two dates. It counts
the number of Sundays between date1
and
date2
. DateDiff
counts date2
if it ...
Get VB.NET Language Pocket Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.