DateAdd() Function
This function returns a date value based on adding an interval of time. It will be more clear by going through the following examples.
Syntax :
DateAdd ( interval , number, date )
Interval :
This is a required argument. This is a string expression which specify the interval type but not the quantity. For example, Minute, second, hour, day etc. Below table has all the possible Interval types.
Number:
This is a required argument. This is the number of interval we want to add in the date time. This can be positive or negative. For future dates, positive and for past dates, negative values.
Date:
This is a required argument. This is date in which you want to add that interval.
Interval | Description |
---|---|
yyyy | Year |
q | Quarter |
m | Month |
y | Day of year (same as Day) |
d | Day |
w | Weekday (same as Day) |
ww | Week |
h | Hour |
n | Minute |
s | Second |
Example:
You can use the DateAdd function to add or subtract a specified time interval from a date. For example, you can use DateAdd to calculate a date 2 Months from today or a time 30 minutes from now.
The DateAdd function won’t return an invalid date. The following example adds one month to January 31:
In this case, DateAdd returns 02-Jan-95.
This link has more details:
http://www.techonthenet.com/excel/formulas/dateadd.php
Hi Vishwa.
You have done simply nice work.
But I can’t use DateAdd function in my excel. Whether it needs to download or use any VBA code for it? Where i can get it? Please help.
Hi Abhijeet,
This is a VBA function which you can use it in VBA code for calculate any date time for any given interval as explained in the examples.
Let me know if you need any further information on this
Hi Vishwa,
But where can I get VBA code for it?