DateValue

This function is similar to the CVDate and CDate functions. For a discussion of the main differences between these functions, see the “DateValue and CDate are not the same” section. The DateValue function will return a value that can be interpreted as a date. It is preferable to “convert” any dates that might be stored as strings using this function.

Return value The return values for these functions are described in the “CDate and CVDate” section (under “Return value”) on page 418.

Arguments The normal argument for this function is a string variable with a date string value, although in Visual Basic 4 and 5, you can use any valid date expression.

Y2K issues The Y2K issues for these functions are covered in the “CDate and CVDate” section (under “Y2K issues”) on page 419.

Other issues In Visual Basic 3, if you try to use DateValue on a short date that is in the wrong international format, you’ll get an error 5: “Illegal function call.” For example, in the U.K., the short date format is dd/mm/yy; if I try to use DateValue on a U.S. formatted short date such as the following, the code will error:

MsgBox DateValue("12/31/99")