BUG: Format Function Returns Incorrect Date or NumberLast reviewed: February 16, 1998Article ID: Q180927 |
The information in this article applies to:
SYMPTOMSAn incorrect date is returned from the Format function.
CAUSEThis problem can occur when the Grouping Symbol in the Regional Settings is set to a period (.). For example, if your Regional Setting is "German(Standard)," the following line of code returns 5.30.1985 instead of 1.31.1997 as expected when typed into the debug window:
?Format("31.1.97", "m.d.yyyy")This problem is caused by the way the Format function handles the period character when formatting. In this case, the Format function simply ignores the period characters in the value before formatting occurs. In other words, Visual Basic converts the date 31.1.97 to the Long value 31197, so you receive the same result as if you typed:
?Format(31197, "m.d.yyyy") RESOLUTIONThis problem can be avoided by converting the date to be formatted to a Date type before it is passed to the Format function. For example, if you have this statement:
?Format("31.1.97", "m.d.yyyy")change it to:
?Format(CDate("31.1.97"), "m.d.yyyy")Because the Format function is capable of formatting several data types, it is a good idea to always pass the value to be formatted as the specific data type it represents to ensure there is no ambiguity.
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATION
Steps to Reproduce Behavior
Keywords : GnrlVB vbwin vb5all Version : WINDOWS:5.0 Platform : WINDOWS Issue type : kbbug |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |