ParseDate Function
Parses a date passed as a String and creates a Date object.
Syntax
result = ParseDate( Text, ByRef ParsedDate )
Parameters | ||
Text |
The Date string to be parsed. |
|
ByRef ParsedDate |
After successful call, contains the parsed date as a Date object. |
Return Value | ||
Result |
Returns True if Text was successfully parsed. |
Notes
The Text parameter must be a valid String representation of a Date. You can use the slash, the dash, the period, or the space to separate the Month, Day, and Year. For example, the following are valid String representations: 12/14/1341, 12-14-1341, 12.14.1341, 14Dec1341, 14.Dec.1341, and 14 Dec. 1341.
ParseDate honors the Date Format settings of the user's computer. For example, the string "12/11/2004" will be parsed as the eleventh of December in the US. If the computer is configured for the British date format, it will be parsed as the twelfth of November.
ParseDate will parse dates based on the user's locale even if the user's locale is a Unicode-only locale.
If you use only the last two digits of the year, the current century is assumed.
ParseDate does not parse the Time value of a Date, if present.
Example
The following code displays the parsed Date in a message box in the Abbreviated Date format. You can use any Date property to return corresponding values, e.g., the Day, Month, and Year properties hold the day, month, and year of the passed Date.
Dim theTrueBool as Boolean
thetruebool=ParseDate ("14Dec1341",theDate)
If theTrueBool then
MsgBox thedate.AbbreviatedDate
else
MsgBox "Invalid Date format!"
end if
See Also