我正在嘗試使用Excel的DateAdd函數來查找下一個工作日。DateAdd的語法
它提供了相同的結果,無論您是使用d,w還是y作爲句號參數。
我試了下面的代碼,並在所有3列中得到相同的結果。
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
結果:
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 2009-09-19 2009-09-19 2009-09-19
提取物。
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
...
張貼瞭解決方法,我知道什麼WW和YYYY做到這一點不是問題 我想!下一個工作日(或工作日) – 2009-09-16 13:03:47
@Patrick工作日!=工作日增加一個工作日到一個日期只需增加到一週的第二天,例如在星期五加一個星期六就表示星期六的日期。有一天,你能指出任何文件,否則會建議? – Glen 2009-09-16 13:11:08
編輯我的答案一點點... – Buggabill 2009-09-16 13:21:55