Name
DateDiff Function
Class
Microsoft.VisualBasic.DateAndTime
Syntax
DateDiff(interval, date1, date2[, dayofweek[, weekofyear]]
)
-
interval
Use: Required
Data Type: String or
DateInterval
enumA String expression (see the first item in Section ) or a member of the
DateInterval
enumeration (see the second item in Section ) that specifies the units of time used to express the difference betweendate1
anddate2
-
date1, date2
Use: Required
Data Type: Date or a literal date
The starting and ending dates, whose difference is computed as
date2
-
date1
-
dayofweek
Use: Optional
Data Type:
FirstDayOfWeek
enumA member of the
FirstDayOfWeek
enum-
weekofyear
Use: Optional
Data Type:
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.
Rules at a Glance
interval
can be one of the following literal strings:
String |
Description |
---|---|
|
Year |
|
Quarter |
|
Month |
|
Day of year |
|
Day |
|
Weekday |
|
Week |
|
Hour |
|
Minute |
|
Second |
interval
can also be a member of theDateInterval
enum:Enum DateInterval Day DayOfYear Hour Minute Month Quarter Second Week Weekday WeekOfYear End Enum
To calculate the number of days between
date1
anddate2
, you can use either of theDateInterval
constants,DayOfYear
orDay
, or the string ...
Get VB .NET Language in a Nutshell 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.