DateAdd

Top  Previous  Next

S

A

W

WS

ü

ü

Syntax -

DateAdd <variable name> <DateValue> <NumberOfUnits> {"DAYS"|"WEEKS"|"MONTHS"|"YEARS" | "WORKDAYS"}

        Where:

       <variable name> is the user defined name that is assigned to the variable.

       <DateValue> is a literal string that represents a valid date or a variable that contains a date.

       <NumberOfUnits> is an integer or a variable that contains an integer.

 

Description:

This command is used to create a date by adding (or subtracting) the <NumberOfUnits> to the specified days, workdays, weeks, months or years component of the <DateValue>.  The new date is stored as the <variable name>.  To subtract, use a negative value for the <NumberOfUnits>.  When using the WORKDAYS option, EMUE adds or subtracts days while excluding weekends.

 

Note: This command accommodates the different lengths of the months and leap years when computing the new date.

 

Sample 1:

The following statement uses DateAdd to add 3 weeks to the date of “02/20/2004”. The resulting date of “03/12/2004” is stored as NewDate. This calculation included the fact that 2004 was a leap year and the last day of February was the 29Th.

DateAdd NewDate "2/20/2004" 3 "WEEKS"

 

Sample 2:

The following statement uses DateAdd to add 4 work days to the date of “02/20/2004”. The resulting date of “02/26/2004” is stored as NewDate.

DateAdd NewDate "2/20/2004" 4 "WORKDAYS"