DateAdd Function

Adds a date or time interval to a given date a number of times and returns the resulting date.

Syntax:


DateAdd (interval As String, number As Long, date As Date) As Date

傳回值類型

包含日期的變體。

Parameters:

interval - A string expression from the following table, specifying the date or time interval.

interval (string value)

說明

yyyy

q

m

y

一年的天數

w

工作日

ww

一年的週數

d

h

n

s


number - A numerical expression specifying how many times the interval value will be added when positive or subtracted when negative.

date - A given date or the name of a Variant variable containing a date. The interval value will be added number times to this date.

Date literals allow to specify unambiguous date variables that are independent from the current language. Literals are enclosed between hash signs #. Possible formats are:

Example:


Sub example_dateadd
    MsgBox DateAdd("m", 1, #1/31/2004#) &" - "& DateAdd(date:=#2005-01-31#, interval:="m", number:=1)
End Sub

Please support us!