DateAdd() in Classic ASP

DateAdd() returns a Date value after adding or subtracting a specified interval. Use a positive number to move forward and a negative number to move backward.

Syntax

DateAdd(interval, number, date)

Add five years

Dim d_today, d_added
d_today = Date
Response.Write "Today: " & d_today & "<br>"
d_added = DateAdd("yyyy", 5, d_today)
Response.Write "Five years later: " & d_added

Add six months

d_added = DateAdd("m", 6, d_today)

DateAdd() adjusts end-of-month dates rather than returning an impossible date. For example, adding one month to January 31 moves to the last valid day of February.

Leap-year example

d_added = DateAdd("d", 32, #1/28/2004#)

The result is February 29, 2004. The same calculation from January 28, 2003 reaches March 1, 2003.

d_added = DateAdd("d", 32, #1/28/2003#)

DateAdd interval codes

IntervalMeaning
yyyyYear
qQuarter
mMonth
y / d / wDay-based interval
wwWeek
hHour
nMinute
sSecond
Weekday note: with DateAdd(), the w interval does not mean “business days.” It adds ordinary days.

ASP Home






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer