DIAdem Help

Content Type
Programming Language
Current manual
Table of Contents

Method: DateDiff for VBS

Method: DateDiff for VBS

Specifies the number of timespans between two dates.

vDateDiff = Object.DateDiff(interval, date1, date2, [firstdayofweek], [firstdayofyear])
ObjectVBS
Object with this method. You do not need to specify this object.
intervalVariant
Specifies the timespan. The following settings are possible.
"yyyy"Year
"q" Quarter
"m" Month
"y" Day of the year
"d" Day
"w" Weekday
"ww" Week of the year
"h" Hour
"n" Minute
"s" Second
date1Variant
Specifies the first date. If you do not enter the year, the DateDiff method uses the current year.
date2Variant
Specifies the second date. If you do not enter the year, the DateDiff method uses the current year.
[firstdayofweek]Variant
Specifies the weekday. Possible values are vbSunday, vbMonday, vbTuesday, vbWednesday, vbThursday, vbFriday, vbSaturday and vbUseSystem. If you do not enter a value, the DateDiff method uses Sunday. This setting only considers the method for the "w" and "ww" timespans.
[firstdayofyear]Variant
Specifies the first week of the year. Possible values are vbFirstJan1, vbFirstFourDays, vbFirstFullWeek, and vbUseSystem. If you do not enter a value, the DateDiff method uses January 1.
vDateDiffVariant
Receives the number of timespans.

The following example returns various timespans:

MyDate = DateDiff("yyyy", #31/12/2001#, #01/01/2002#)
Call MsgBox("Years left: " & MyDate)
MyDate = DateDiff("ww", "01/01", Date)
Call MsgBox("Week of year: " & MyDate)
MyDate = DateDiff("ww", #01 January#, Date)
Call MsgBox("Week of year: " & MyDate)

Related Topics

DateAdd | DateDiff | DatePart | DateSerial | DateValue | Date | Day | Hour | Minute | MonthName | Month | Now | Second | TimeSerial | TimeValue | Time | Timer | Weekday | WeekdayName | Year

In This Section
Was this information helpful?