Date Manipulation with VBScript
Beyond simply displaying the date, VBScript provides a number of functions
That's allow to manipulate dates. The DATEADD (interval, number, date)
and DateDiff (interval, date1, date2) are helpful functions that are
Usually left for the developer to write.
Both functions require to the interval argument. This argument
Specifies the interval to the "date" or to compare the dates.
The DATEADD (interval, number, date) function returns a date is the
Specified number of intervals from the given date. The DateDiff (interval,
Date1, Date2) function returns the number of intervals between date1 and
Date2.
There is also a handy function called DateSerial (year, month, day)
Returns a variant of the Date subtype. This function was very useful when
You are need to create a date (such as Christmas) for use in the DateDiff ()
function.
The following code shows these three functions in action:
<% dtoday = Date ()%>
In ten days it'll be
<%= DateAdd ("D", Dtoday)%>
<P>
<% Dchristmas = DateSerial (1998,12,25)%>
Christmas is just <%= DateDiff ("D", Dtoday, Dchristmas)%> days away!
From--zd Journals ' Active Server developers Journal