$CALCDATE (date calculation function)
$CALCDATE adds a specified number of days or hours to a date or time, then returns the arithmetic result. You can acquire relative dates and times, such as two days before or three hours after a specified date or time, without having to mentally calculate the carryover of months, days, or hours.
Syntax
return-value=$CALCDATE(date/time,unit,value-to-add,output-format)
Values
-
return-value
Specifies the name of the variable into which the acquired date or time is to be set.
-
date/time
Specifies a constant or a variable. A constant must be enclosed in single quotation marks (').
date/time can be specified in either of the following formats:
-
yyyy/mm/dd hh:mm:ss or yyyy-mm-dd hh:mm:ss
These formats specify both a date and a time; however, the hh:mm:ss part can be omitted.
-
No specification
The date and time the embedded function is executed is assumed.
-
-
unit
Specifies a constant or a variable. A constant must be enclosed in single quotation marks (').
The following lists the variables that can be specified:
-
d
Specifies that a number of days is to be calculated.
-
h
Specifies that a number of hours is to be calculated.
-
n
Specifies that a number of minutes is to be calculated.
-
s
Specifies that a number of seconds is to be calculated.
-
-
value-to-add
Specifies a constant or a variable. A constant must be enclosed in single quotation marks (').
An integer must be specified as the value.
-
output-format
Specifies the output format of the date and time, either as a constant or a variable. For details about the output format, see $DATETIME (get date/time).
Status
The following table lists and describes the possible statuses:
Status |
Description |
---|---|
NORMAL |
Normal end |
Script execution interrupted |
Indicates one of the following:
|
Example
The following example outputs the date that is 10 days before 2005/04/11:
DATE = $CALCDATE('2005/04/11','d','-10','%Y/%m/%d') $ECHO(DATE)
- Execution result:
-
2005/04/01