Skip to content

DateAdd - Built-in Date & Time Function

Purpose

DateAdd returns a datetime with the specified interval added.

Syntax

DateAdd(str, int, date)

Arguments

Argument Required Description
str Yes String expression containing an interval specifier
int Yes Integer expression holding the amount to add
date Yes Datetime expression to which the interval is added

Valid interval specifiers for str:

  • D — day
  • H — hour
  • N — minute
  • S — second

Returns

DateTime

See also

Example

// Adds 2 days to the order date
Return DateAdd ('D', 2, {OrderHeader.Order_Date})
// Print order date and date to pay
Return ('Ordered at: ' + CStr ({OrderHeader.Order_Date}) + ', pay before: '
    + CStr (DateAdd ('D', 14, {OrderHeader.Order_Date})))
Return 'Ordered at: ' + FormatDate ({OrderHeader.Order_Date}, drCustomDateMask, "MMMM. d, yyyy") + ', pay before: '
    + FormatDate (DateAdd ('D', 14, {OrderHeader.Order_Date}), drCustomDateMask, "MMMM. d, yyyy")

Notes

  • When the arguments cannot be converted to the specified type, a runtime error is generated.
  • Use the FormatDate function for more control over the formatting of the date value.