How to Add Years to a Date Expression

Last reviewed: June 27, 1995
Article ID: Q128069
The information in this article applies to:
  • Microsoft FoxPro for Windows, version 2.6a

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


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 27, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.