CALC_MONTHS function
Functions
CALC_MONTHS{[DATE],MONTH}
This function uses the value specified by MONTH to perform a date calculation on the date specified by DATE, and then returns the calculated value.
If you do not specify the DATE, this function returns a value resulting from a date calculation using the mapped character string. If the mapped character string is not in date format, the function results in an error at the time of conversion.
The returned value also includes the time (HH:MI:SS).
Parameters
DATE
Specify the date. (This parameter can be omitted.).
If the date specified is not in date format, the function results in an error at the time of conversion.
If the mapped character string is null, the current date is used.
You can also use $DSTR to specify DATE.
MONTH
Specify the number of months to be used for the date calculation. (This parameter cannot be omitted.)
If a non-numeric value is used, the function results in an error at the time of conversion.
When a decimal is used, the value is treated as an integer, truncating the decimal places. Null is treated as 0.
You can also use $VAR, $INUM, $INAME, $DNUM, $DSTR, and $MINUM to specify MONTH.
-
If an end-of-month date is specified for DATE, the end-of-month date is always returned after the date calculation.
-
If you specify a date other than the end-of-month date for DATE, and the result of the date calculation is a date after the end of the month, the function returns the end-of-month date.
Example: DATE: 2011/3/30, MONTH: -1 -> 2011/2/28 is returned.
Example
The table below describes examples of DATE, MONTH, and the result.
The returned value also includes the time (HH:MI:SS).
DATE |
MONTH |
Result |
---|---|---|
2011/6/30 |
-3 |
2011/3/31 |
2011/5/31 |
-3 |
2011/2/28 |
2008/2/29 |
-12 |
2007/2/28 |
2011/3/30 |
-1.6 |
2011/2/28 |
2011/6/30 |
1.2 |
2011/7/31 |
2008/2/29 |
1.8 |
2008/3/31 |
2011/6/30 |
0 |
2011/6/30 |