Hitachi

JP1 Version 11 JP1/Script Description and Reference (For Windows Systems)


8.4.10 CalcDate (add and subtract dates)

Purpose

Adds or subtracts a specified number of years, months, or days to or from a specified date, and returns the calculation result.

Syntax
CalcDate (Date, Calc, [Years], [Months] [, Days])
Arguments
Date

Write the date in yyyy/mm/dd format. Numbers specified in the range 0 to 69 in yyyy are read as 2000 to 2069.

If an invalid value is specified for mm, an error occurs. However, if an invalid value is specified for dd, no error occurs. Instead, the CalcDate command replaces the specified date with the equivalent valid date and returns the result.

For example, if 1999/12/33 (a nonexistent date) were specified, the CalcDate command would replace the specified date with the valid date 2000/01/02.

Calc

Specify the calculation to perform. Write either of the following values:

Value

Meaning

Minus

Subtraction: Return the date specified in Date, minus the years, months, or days specified in Years, Months, and/or Days.

Plus

Addition: Return the date specified in Date, plus the years, months, or days specified in Years, Months, and/or Days.

Years

Write the years as 0 or a number, or as a variable that stores this value.

This value is optional. If you omit this value, 0 is assumed.

Months

Write the months as 0 or a number, or as a variable that stores this value.

This value is optional. If you omit this value, 0 is assumed.

Days

Write the days as 0 or a number, or as a variable that stores this value.

This value is optional. If you omit this value, 0 is assumed.

Description

The CalcDate command adds or subtracts a specified number of years, months, or days to or from a specified date, and returns the calculation result in yyyy/mm/dd format.

If the calculated date does not exist, the command returns the closest future date. For example, if the calculated date is 1999/02/29 (non-existent), the returned date will be 1999/03/01 (existent).

A zero-length string ("") is returned if an error occurs.

Example
' Display the date 10 days before today.
Dim result1
result1 = CalcDate (Date(), Minus, , , 10)
MessageBox ("The date 10 days ago is "+result1+".")
JP1/Script version

Supported from JP1/Script 05-20.