Printer Version |
Table of Contents |
Project Home Page |

.CATEGORY....: functions

.DISCUSSION..:

Function name is "m" for "month arithmetic".

Here is an example:

Fdate /Fm /Nnumdays /Adate /Iformat /OformatThis function adds /N months to /Adate, and produces a date in /Oformat format. It can be used to do monthly subtraction by making the number in the /N parameter a negative number.

.EXAMPLES....:

.DISCUSSION..:Fdate /Fm /N1 /A03-15-1992 /Imm-dd-ccyy /Omm-dd-ccyy produces: 04-15-1992 Fdate /Fm /N-1 /A03-30-1991 /Imm-dd-ccyy /Omm-dd-ccyy produces: 02-28-1991 Fdate /Fm /N-1 /A03-30-1992 /Imm-dd-ccyy /Omm-dd-ccyy produces: 02-29-1992

__Fdate's MONTH DATE ARITHMETIC IS SMART!__

Fdate's month arithmetic is smarter than that. If Fdate finds that a simple month-arithmetic operation produces an invalid date, it subtracts the minimum number of days required to produce a valid date.

- In the second example, it produces February 28, 1991,
the last date in February, 1991.

- In the third example, it produces February 29, 1992
because 1992 is a leap year.

- Telling Fdate to add 12 months to February 29, 1992 produces a
result of February 28, 1993, since 1993 is not a leap year.

- Prime Computer's MAGSAV failed at midnight [on Feb 29, 1992]... G. M. Lack noted that MAGSAV probably failed on leap-day because it tried to increment the year by one to set a tape label expiration date, and the resulting nonexistent date of Feb 29, 1993 threw it for a loop.