VBA/Excel/Access/Word/Date Functions/DateAdd — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 15:48, 26 мая 2010
Add value to Date
<source lang="vb">
Sub AddADay()
Dim dtInitialDate As Date dtInitialDate = DateAdd("d", 1, dtInitialDate) Debug.Print dtInitialDate
End Sub
</source>
DateAdd(interval, number, date) returns a Variant/Date containing the date of the specified interval after the specified date
<source lang="vb">
Sub dateDemo2()
Debug.Print DateAdd("m", 1, "6/3/06"); returns; 7 / 3 / 2006#
End Sub
</source>
DateAdd returns the result of adding or subtracting a specified period of time to a date:
<source lang="vb">
Sub DateAddExample()
Debug.Print DateAdd("d", 3, Now) "Today plus 3 days Debug.Print DateAdd("m", 3, Now) "Today plus 3 months Debug.Print DateAdd("yyyy", 3, Now) "Today plus 3 years Debug.Print DateAdd("q", 3, Now) "Today plus 3 quarters Debug.Print DateAdd("ww", 3, Now) "Today plus 3 weeks Debug.Print DateAdd("ww", -3, Now) "Today minus 3 weeks
End Sub
</source>