DATESUB        Subtract specified number of days from a date variable

Top  Previous  Next

Syntax:

DATESUB

[ variable ] [ amount ]

Arguments:

[ variable ]

A variable that was previously assigned a string value formatted as a date in the style of mm-dd-yy.

 

[ amount ]

A variable or a numeric constant representing the number of days to subtract from the date value stored in [ variable ].

Options:

none

 

 

 

This script command is used to calculate a new date by subtracting the specified number of days from the date value stored in the [ variable ] argument. The date string value must be formatted in the same manner as the %date internal variable.

 

Note: The %date internal variable should not be passed directly in the [ variable ] argument of this command. To use the value of %date with DATESUB you must first assign its value to a user defined variable and then pass that user defined variable to the [ variable ] argument.

 

Consider the example below where 14 days is subtract from a variable containing the current date.

 

SET today = %date

DATESUB today 14

DISPLAY today

 

The number of days to subtract may also be expressed in a variable as shown below.

 

SET today = %date

SETNUM x = 14

DATESUB today x

DISPLAY today

 

Dates before January 1st, 1970 ("01-01-70") are not supported.

 

Related command(s): DATEADD, IFDATE, DATETIMEADD, DATETIMESUB, IFDATETIME  

See also: Using the %date, %datetime, and %time Variables, Comparing Local and Remote Files, Comparing File Dates and Times