XL97: Problems When Macro Opens/Saves Text Files with Dates

Last reviewed: January 14, 1998
Article ID: Q171278
The information in this article applies to:
  • Microsoft Excel 97 for Windows

SYMPTOMS

In Microsoft Excel 97, if you run a Visual Basic for Applications macro that opens or saves a text file that contains dates, the following problems may occur:

  • The month, day, and/or year of the dates may be reversed. For example, if the text file contains the date 5/7/97, the date may be interpreted as May 7, 1997 instead of July 5, 1997.
  • Some dates may be converted into text strings. This problem may occur if the day or year of a date is greater than 12.

    For example, if the text file contains the date 30/7/97 (July 30, 1997), it may be converted into the text string "30/7/97" (without quotation marks).

CAUSE

These problems may occur if you are using regional settings that use a date order of day-month-year or year-month-day.

RESOLUTION

To correct this problem, install Microsoft Excel 97 Service Release 1 (SR-1).

STATUS

Microsoft has confirmed this to be a problem in Microsoft Excel 97. This problem was corrected in Microsoft Excel 97 SR-1.

For additional information about SR-1, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q172475
   TITLE     : OFF97: How to Obtain and Install MS Office 97 SR-1

MORE INFORMATION

In Microsoft Excel, dates contain three elements: a year, a month, and a day. The order in which these elements are displayed in a date depends on the regional settings in use on your computer. These regional settings vary from country to country. The three main ordering methods used for dates in Microsoft Excel are listed in the following table.

   Order            July 5, 1997 represented as
   --------------------------------------------

   month-day-year   7/5/97
   day-month-year   5/7/97
   year-month-day   97/7/5

The first order, month-day-year, is used in the following regional settings under Microsoft Windows 95 and Microsoft Windows NT:

   English (United States)
   Spanish (Dominican Republic)
   Spanish (Panama)

If your computer uses any of these three regional settings, the problems described in the "Symptoms" section in this article do not occur.

However, if you use any other regional settings, you may encounter the problems described in the "Symptoms" section in this article when you run a Visual Basic macro that opens or saves a text file that contains dates. This is because Microsoft Excel 97 may incorrectly use the month-day-year order for dates. As a result, dates may be converted to the month-day-year order. The following table contains an example.

   Order            Date                    Converted to this order
   ----------------------------------------------------------------

   Day-month-year   5/7/97 (July 5, 1997)   5/7/97 (May 7, 1997)
   Year-month-day   97/7/5 (July 5, 1997)   97/7/5 (text string)

Note that if the converted date is not valid in the month-day-year order, the date is converted to a text string.

These problems do not occur if you manually open or save a text file that contains dates. The problem occurs only when you use a macro to open or save such a text file.

This problem does not occur in Microsoft Excel 97 SR-1. This new release of Microsoft Excel 97 works correctly with all regional settings when you use a macro to open or save text files that contain dates.


Additional query words: XL97 australian canadian new zealand french german
italian british norwegian portuguese swedish danish ireland south africa
argentina chile colombia paraguay uruguay peru mexican costa rica ecuador
guatemala peru venezuela brazilian swiss icelandic indonesian afrikaans
basque catalan dutch belgian finnish luxembourg austrian liechtenstein
caribbean jamaica nynorsk bokmal sr1 y2k year2000
Keywords : kbprg
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbbug
Solution Type : kbfix


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