Name
DateDiff Function — Microsoft.VisualBasic.DateAndTime
Synopsis
DateDiff(interval, date1, date2[,dayofweek[,weekofyear]])
intervalrequired; String orDateIntervalenumSpecifies the time unit used to express the difference between
date1anddate2date1,date2required; Date or a literal dateThe starting and ending dates, whose difference is computed as
date2-date1dayofweekoptional;FirstDayOfWeekenumA member of the
FirstDayOfWeekenumweekofyearoptional;FirstWeekOfYearenumA member of the
FirstWeekOfYearenum
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access