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.
DateAdd(interval, number, date)
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
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.
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#)
| Interval | Meaning |
|---|---|
| yyyy | Year |
| q | Quarter |
| m | Month |
| y / d / w | Day-based interval |
| ww | Week |
| h | Hour |
| n | Minute |
| s | Second |
DateAdd(), the w interval does not mean “business days.” It adds ordinary days.Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.