Method: CDate for VBS
- Updated2024-09-12
- 1 minute(s) read
Methods > Method: CDate for VBS
Method: CDate for VBS
Converts an expression into the Variant type with the Date subtype.
vCDate = Object.CDate(expression)
| Object | VBS Object with this method. You do not need to specify this object. |
| expression | Variant Specifies any Date expression. |
| vCDate | Variant Receives the converted value. During conversion the CDate method considers the locale settings of your computer, for example decimal points and thousands separators. The CDate method recognizes date literals, time literals, and specific numbers that are within the valid date range. If the method converts numbers into a date, it uses the integer part for the date and the decimal place for the time. The CDate method does not recognize character strings for weekdays. |
The following example converts texts into a date:
Dim MyDate, MyTime MyDate = "April/30/2011" Call MsgBox(CDate(MyDate)) ' Returns a date MyTime = "11:55:47 PM" Call MsgBox(CDate(MyTime)) ' Returns a time