I am trying to use Excel the DateAdd function to find the next working day. It seems that Excel is not working as expected with this function, and always provides the same result wether you use d, w or y for the period argument. (by the way the explanations of the "y" value are beyond my logic).
I tried the following code, and get identicial results in all 3 columns. Am I mad ?
Sub test()
Dim i As Integer
For i = 1 To 9
Debug.Print i;
Debug.Print DateAdd("d", i, #9/10/2009#);
Debug.Print DateAdd("w", i, #9/10/2009#);
Debug.Print DateAdd("y", i, #9/10/2009#)
Next i
End Sub
Result:
1 11/09/2009 11/09/2009 11/09/2009
2 12/09/2009 12/09/2009 12/09/2009
3 13/09/2009 13/09/2009 13/09/2009
4 14/09/2009 14/09/2009 14/09/2009
5 15/09/2009 15/09/2009 15/09/2009
6 16/09/2009 16/09/2009 16/09/2009
7 17/09/2009 17/09/2009 17/09/2009
8 18/09/2009 18/09/2009 18/09/2009
9 19/09/2009 19/09/2009 19/09/2009
Extract from the documentation: Returns a Variant (Date) containing a date to which a specified time interval has been added.
Syntax
DateAdd(interval, number, date)
...
interval Required. String expression that is the interval of time you want to add.
....
The interval argument has these settings:
Setting Description
yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week
...