Adding and Subtracting Dates and Times
To add or subtract a specified interval to or from a date, use the DateAdd function. This function can be useful for adding dates and for performing tasks such as determining what day of the week a particular future date falls on. You can add any date interval to an existing date: years, quarters, months, weeks, or days. You can also add time intervals of hours, minutes, or seconds. The syntax is
DateAdd(interval, number, date)
Interval specifies the type of interval being added. It is a string expression, as shown in Table 16.1. Number is the number of intervals to add. Use a negative value to subtract intervals. Date is the date being added to or subtracted from.
Get Office® XP Development with VBA now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.