VBA DateAdd function

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 4.50 out of 5)
Loading...

DateAdd Function Description

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

Syntax

The syntax for the DateAdd function in VBA is:

DateAdd ( interval, number, date )

Parameters

interval
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

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

date
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"

Simply the best place to learn Excel VBA