How to Add Years to a Date Expression

ID: Q128069

The information in this article applies to:

Use the fuction GOMONTH() to add years to a date expression. GOMONTH() returns the date that is a specified number of months before or after a given date or datetime expression. Here's the syntax:

   GOMONTH(<expd>,<expN>)

The <expd> specifies a date expression for which GOMONTH() returns the date. The <expN> specifies the number of months from the date or datetime.

If <expN> is positive, GOMONTH() returns a date that is <expN> months after the date. If nNumberOfMonths is negative, GOMONTH() returns a date that is <expN> months before the date.

For example, if you have a date expression in a variable like this:

   mydate = {03/03/95}   && Enter this in the Command window
   ? mydate

And you want to add a number of years to that date, as shown here:

   addyears=3   && Enter this in the Command window
   ? addyears

You could use the GOMONTH() function as in this example:

  newdate=GOMONTH(mydate,12 * addyears) && Enter this in the Command window
  ? newdate

Additional reference words: FoxWin 2.60a KBCategory: kbprg KBSubcategory: FxprgGeneral

Last Reviewed: June 27, 1995