ID Number: Q84115
1.00
WINDOWS
buglist1.00
Summary:
If you omit the year portion of the DateValue function argument,
DateValue uses the current year from the computer's system date.
However, if you also pass an invalid day for the month, DateValue
interprets the month as the year and the day will default to 1. For
example, 3/30 will be interpreted as 3/30/92, but 3/44 will not
produce an error message, and will be interpreted as 3/1/44.
Microsoft has confirmed this to be a problem in Microsoft Visual Basic
programming system version 1.0 for Windows. We are researching this
problem and will post new information here as it becomes available.
More Information:
The DateValue function returns a serial number that represents the
date of the string argument. The date string can be in various forms.
For example:
3/30/92
3/30/1992
March 30, 1992
Mar. 30, 1992
30-Mar-1992
30 March 92
The year portion of the string argument may be omitted, in which case
the current year of the computer's system date is used. For example,
3/30 will cause DateValue to return the serial number that represents
3/30/92 (if 1992 is the year of the system date).
However, if the year is omitted and the day is not a valid day for
that month of the current year, the month will be interpreted as
the year and the day will default to 1. So 3/44 will be interpreted
as 3/1/44.
Steps to Reproduce Problem
--------------------------
1. Run Visual Basic, or from the File menu, choose New Project (ALT,
F, N) if Visual Basic is already running. Form1 is created by
default.
2. Add the following code to the Form_Load event procedure:
Sub Form_Load ()
Debug.Print "3/30 ="; DateValue("3/30")
Debug.Print "3/30/92 ="; DateValue("3/30/92")
Debug.Print
Debug.Print "3/44 ="; DateValue("3/44")
Debug.Print "3/1/44 ="; DateValue("3/1/44")
End Sub
3. Press F5 to run the program.
Notice in the Immediate window that the serial numbers returned by the
DateValue function for 3/30 and 3/30/92 are the same (assuming 1992 is
the current year of the system date), and the serial numbers for 3/44
and 3/1/44 are the same. Also, no error message was produced.
Additional reference words: 1.00