DateAdd

The DateAdd function returns a date to which a specified time interval has been added.

Syntax :

DateAdd(interval,number,date)
Parameters Description
interval Required. The interval you want to add
Can take the following values:
yyyy - Year
q - Quarter
m - Monthly - Day of year
d - Day
w - Weekday
ww - Week of year
h - Hour
n - Minute
s - Second
number Required. The number of interval you want to add. Can either be positive, for dates in the future , or negative, for dates in the past.
date Required. Variant or literal representing the date in which interval is added.

Examples :

Example 1

To use Parameters :

dDateAdd = (DateAdd("yyyy",1,"31-Jan-20") & "  ")
dDateAdd = (DateAdd("q",1,"31-Jan-20") & "  ")
dDateAdd = (DateAdd("m",1,"31-Jan-20") & "  ")
dDateAdd = (DateAdd("y",1,"31-Jan-20") & "  ") 
dDateAdd = (DateAdd("d",1,"31-Jan-20") & "  ")
dDateAdd = (DateAdd("w",1,"31-Jan-20") & "  ")
dDateAdd = (DateAdd("ww",1,"31-Jan-20") & "  ")
dDateAdd = (DateAdd("h",1,"31-Jan-20 08:50:00") & "  ")
dDateAdd = (DateAdd("n",1,"31-Jan-20 08:50:00") & "  ")
dDateAdd = (DateAdd("s",1,"31-Jan-20 08:50:00") & "  ")

DEBUG(dDateAdd)

Result :

dDateAdd
= 1/31/2021
= 4/30/2020
= 2/28/2020
= 2/1/2020
= 2/1/2020
= 2/1/2020
= 2/7/2020
= 1/31/2020 9:50:00 AM
= 1/31/2020 8:51:00 AM
= 1/31/2020 8:50:01 AM

Example 2 :

Subtract one month from January 21,2020 :

dDateAdd = (DateAdd("m",-1,"31-Jan-20"))
DEBUG(dDateAdd)

Result :

dDateAdd
= 12/31/2019

Example 3

To add one day form now :

dDateAdd = (DateAdd("d",1,Now()))
DEBUG(dDateAdd)

Result :

dDateAdd
= 2/25/2020 4:44:59 PM