Date/Time Functions Give Wrong Results After CURRENCY Format$

ID Number: Q77579

1.00

WINDOWS

buglist1.00

Summary:

The Year, Month, Day, Weekday, Hour, Minute, and Second functions give

incorrect results just after using the Format$ function on a CURRENCY

data type. The serial number used is correct, but the aforementioned

functions using that serial number produce incorrect results.

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.

To work around this problem, invoke the Format$ function again using a

non-CURRENCY data type. The Year, Month, Day, Weekday, Hour, Minute,

and Second functions will then work correctly.

More Information:

To illustrate the problem, attach the following code to a form:

Sub Form_Click ()

Serial# = Now

Print

Print Format$(0@, "0.00")

Print Serial#

Print Year(Serial#)

Print Month(Serial#)

Print Day(Serial#)

Print Weekday(Serial#)

Print Hour(Serial#)

Print Minute(Serial#)

Print Second(Serial#)

End Sub

The Year, Month, Day, Weekday, Hour, Minute, and Second functions will

produce incorrect results.

To obtain the correct results, format another data type and assign it to

a dummy variable before using the date/time functions. In the sample

code above, attach the following statement after "Print Format$(0@,

"0.00")" and before "Print Year(Serial#)":

dummy$ = Format$(0, "0.00")

This statement will cause the Year, Month, Day, Weekday, Hour, Minute,

and Second functions to produce the correct results.

Additional reference words: 1.00