DateAdd Function

Adds or subtracts a period from a date/time value.

DateAdd (interval, number, date)

Parameters

Interval  -  (Input, expression, Required)

Specifies the interval to add. It should be one of the following predefined constants:

Number  -  (Input, expression, Required)

Specifies the number of intervals to add. If number is negative, then the interval is subtracted (i.e. a date in the past in returned).

Date  -  (Input, expression, Required)

The date value from which to add the interval. If date is specified as a string expression, newlook will convert it to a date/time as long as it contains a date and/or time in the form “mmm d, yyyy” and/or “hh:nn:ss” (e.g. “Feb 1, 1999 10:30:00”).

Return Value

A DateTime value offset by the specified period, or Error if date is not a valid date.

Examples

DateAdd (IntYears, 1, Now())

One year from now

DateAdd (IntQuarters, 1, Now())

Three months from now

DateAdd (IntMonths, 1, Now ())

One month from now

DateAdd (IntWeeks, 1, Now ())

Seven days from now

DateAdd (IntDays, -1, Now ())

Yesterday

DateAdd (IntDays, 1, Now ())

Tomorrow

DateAdd (IntHours, 24, Now ())

Tomorrow

TIP:

Functions are specifically for use in the Macro Editor. Refer to Microsoft's official VB and JScript documentation for scripting equivalents.

See Also

Functions


© 2004-2021 looksoftware. All rights reserved.