Article ID: 180927
Article Last Modified on 6/29/2004
?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")
?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.
Private Sub Form_Click()
Debug.Print Format("31.1.97", "m.d.yyyy")
End Sub
Additional query words: kbVBp500bug kbVBp600fix kbVBA500bug kbVBA600bug KBVBA KBINTL kbVBp kbdsd kbDSupport
Keywords: kbbug kbfix KB180927