We often have to deal with dates when we develop programs for real life situations. Because time has vital place in real life. So when we develop programs we often need to add intervals to the dates. We can use "DateAdd" in those cases.
Here below is a explanation of how to use a "DateAdd". We can use this not only to add dates but also to add weeks, months etc. So it will be very helpful when develop programs which are connected with dates.
Result = DateAdd("d", 1, CDate(Range("A1"))) |
There should be valid date in A1. It will increment that date by a single day.
"d" means we are adding a day.
Below symbols can be used to add other intervals.
s - Second
n - Minute
h - Hour
q - Quarter
m - Month
y - Day of year
yyyy - Year
w - Weekday
ww - Week
This method can be used to substract dates as well. Below will substract 5 days.
Result = DateAdd("d", -5, CDate(Range("A1"))) |