DATETIMESUB        Subtract specified amount from the date time variable

Top  Previous  Next

Syntax:

DATETIMESUB

[ variable ] [ amount ] [ /unit ]

Arguments:

[ variable ]

A variable that was previously assigned a string value formatted as a date and time in the style of Sat Feb 16 11.00.22 2013.

 

[ amount ]

A variable or a numeric constant representing the amount of time to subtract from the date and time value stored in [ variable ].

 

[ /unit ]

The type of time units to add to the date and time value that is stored in [ variable ]. Possible values are: /day /hour /minute and /second.

Options:

none

 

 

 

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

 

Note: The %datetime internal variable should not be passed directly in the [ variable ] argument of this command. To use the value of %datetime with DATETIMESUB 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 subtracted from a variable containing the current date and time.

 

SET today = %datetime

DATETIMESUB today 14 /day

DISPLAY today

 

Consider the example below where 34 minutes is subtracted from a variable containing the current date and time.

 

SET today = %datetime

DATETIMESUB today 34 /minute

DISPLAY today

 

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

 

SET today = %datetime

SETNUM x = 14

DATETIMESUB today x /day

DISPLAY today

 

 

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

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