Printer Version Table of Contents Project Home Page
.FUNCTION....: M - Month Date Arithmetic
.CATEGORY....: functions
Function name is "m" for "month arithmetic".

Here is an example:

       Fdate /Fm /Nnumdays /Adate /Iformat /Oformat
This 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.

 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



Month arithmetic that is done just by subtracting a certain number of months can produce non-existent dates. For example, subtracting one month from March 30, 1991 (as in the second example) could produce a result of February 30, 1991, a date which cannot exist.

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.

Problems with overly-simple date arithmetic are not merely academic. Here is a passage from Peter G. Neumann's INSIDE RISKS column in COMMUNICATIONS OF THE ACM, June 1992 (Vol. 35, No. 6). The column title was "Leap-Year Problems":