XL: Date Returned in a Macro Is Four Years Too EarlyLast reviewed: March 13, 1998Article ID: Q157035 |
The information in this article applies to:
SYMPTOMSWhen you run a macro that uses a date from a worksheet cell, the date returned by the macro may be four years and one day earlier than the actual date.
CAUSEA macro returns a date that is four years and one day earlier when you select "1904 date system" in the Calculation tab of the Options dialog box, and one of the following conditions is true:
WORKAROUNDThe following macro determines whether the 1904 date system is selected, converts a date to the 1900 date system, and returns the expected date. Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/refguide/default.aspTo use the macro, follow these steps:
STATUSMicrosoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONVisual Basic for Applications does not automatically detect the 1904 date system and convert the date as necessary. If a user selects the 1904 date system in Microsoft Excel, and runs a macro that reads a date from a worksheet cell, the difference may be four years and one day (the extra one day accounts for the leap year). For example, a date of 9/1/96 in the 1904 date system may return a date of 8/31/92. The date system discrepancy may occur in Visual Basic when you select the 1904 date system and the macro uses the Value2 property when it stores the date. The Value2 property is a new property in Visual Basic that you can use in Microsoft Office 97. The Value2 property stores variables in the same way as the Value property except that it does not use the Currency or Date data types.
|
Additional query words: XL97 XL7 8.00 7.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |