PRB: Unexpected Date Value Returned from Format FunctionLast reviewed: March 20, 1998Article ID: Q113327 |
3.00
WINDOWS
kbprg kbcode kbprb
The information in this article applies to: - Microsoft Visual Basic programming system for Windows version 3.0
SYMPTOMSWhen using the Date, Time, or Format function to return information about a Date/Time variable, you may get results other than what you expected. For Example, the following prints January:
Print Format$(4, "MMMM") ' Print the Month represented by number 4 CAUSEThe value 4 when interpreted as a date is Jan 3, 1900. Dates are stored in Variants of VarType 7 (Date) as double-precision numbers. This number represents a date from January 1, 100 through December 31, 9999 -- where January 1, 1900 is 2. Negative numbers represent dates prior to December 30, 1899.
WORKAROUNDTo get the string "April" to print when the only date information available is the Month 4, use a function such as DateSerial and supply it with an arbitrary Day and Year.
Step-by-Step Example
STATUSThis behavior is by design.
|
Additional reference words: 3.00 FORMAT FORMAT$ DATESERIAL
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |