VBA DateAdd

DateAdd Function Description

The VBA DateAdd function increments a date with the provided interval (second, minute, hour etc.).

VBA DateAdd Syntax

The syntax for the DateAdd function in VBA is:

DateAdd ( interval, number, date )


A string which defines the type of date/time interval which will be increment to the date. The following are acceptable interval string types:

Interval type Description
yyyy Year
q Quarter
m Month
y Day of the year
d Day
w Weekday
ww Week
h Hour
n Minute
s Second

The number of intervals to be added to date. The type of interval is defined with the interval parameter.

The date which is to be incremented by the defined number of interval.

Example usage

The DateAdd function can be used in VBA code. Let’s look at some VBA DateAdd function examples:

DateAdd "yyyy", 2, "2015/10/11"
'Result: "20157/10/11"

DateAdd "m", 1, "2015/10/11"
'Result: "2015/11/11"

DateAdd"n", 2, "2015/10/11 14:30"
'Result: "2015/10/11 14:32"