ACC: Using Format() and Month() Returns Incorrect Month

Last reviewed: May 28, 1997
Article ID: Q106290
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0, 7.0, 97

SYMPTOMS

Moderate: Requires basic macro, coding, and interoperability skills.

If you use the Format() function on the result of a Month() function, Microsoft Access returns an incorrect result.

CAUSE

The Month() function converts a date to an integer. The Format() function is expecting a date serial number as an argument, but instead receives an integer.

STATUS

This behavior is by design.

MORE INFORMATION

The following sample function returns January instead of April:

   =Format$(Month(#4/30/93#), "mmmm")

To return just the name of the month, use the Format() function without the Month() function. For example, the following expression returns April:

   =Format(#4/30/93#,"mmmm")

If the Month() function is required, use the Choose() function to return the name of the month. The following example demonstrates how to use the Choose() function:

NOTE: In the following example, an underscore (_) is used as a line- continuation character. Remove the underscore from the end of the line when re-creating the example.

   =Choose(Month([datefield]),"January","February","March","April", _
       "May","June","July","August","September","October","November", _
       "December")

REFERENCES

For information about syntax and usage of the Choose function, search the Help Index for "Choose function."


Keywords : ExrOthr kbusage
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Hardware : X86
Issue type : kbprb
Resolution Type : Info_Provided


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: May 28, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.