Article ID: 274238 - Last Review: January 29, 2007 - Revision: 5.4 Date returned in a macro is four years too earlyThis article was previously published under Q274238 SYMPTOMS
When 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.
CAUSE
This behavior occurs when you select the 1904 Date System check box on the Calculation tab of the Preferences dialog box, and when one of the following conditions is true:
WORKAROUNDMicrosoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to 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 requirements.
To see an example of the behavior described in this article, follow these steps:
C1: 1/1/95 D1: Value Property C2: 12/31/90 D2: Application.Max C3: 12/31/90 D3: Value2 Property
to
After you change the line of code, rerun the GetDates1 macro. The correct dates are returned. STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section. MORE INFORMATION
Visual 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 Value2 property stores variables in the same way as the Value property except that it does not use the Currency or Date data types. REFERENCESFor more information about the 1904 date system, click the Office Assistant, type tips on entering dates and times, click Search, and then click a topic to it. Note If the Assistant is hidden, click the Office Assistant button on the standard toolbar. | Article Translations
|
Back to the top
