![]() |
|
|
+ Search |
![]()
|
May 3rd, 2001 12:08
Suzanne L., Gamini Jayarathne, Que's 'Using Visual Basic 4'
To subtract days from a date, use the DateAdd function with a negative
number for the second argument.
Que's 'Using Visual Basic 4' states: (I confirmed it works in VBScript)
The DateAdd function is used as follows:
newdate = DateAdd(interval, numintervals, olddate)
newdate and olddate represent date variables in the equation. olddate
can also be a literal date or a function that returns a date. interval
is a string expression defining the type of time period to be applied.
numintervals specifies the number of time periods added to or
subtracted from olddate. If numintervals is positive, the time
intervals are added to the olddate. If numintervals is negative, the
time intervals are subtracted from olddate.
FYI: interval values are as follows:
"q" Quarters
"m" Months
"w" Weekdays of the same day
"d" Days
"h" Hours
"n" Minutes
"s" Seconds
Example:
To remove one day from the current date (to get yesterday's date):
Dim Yesterday
Yesterday = DateAdd("d",-1,Date)
© 1999-2004 Synop Pty Ltd