DIAdem Help

Method: CDate for VBS

  • Updated2024-09-12
  • 1 minute(s) read

Method: CDate for VBS

Converts an expression into the Variant type with the Date subtype.

vCDate = Object.CDate(expression)
ObjectVBS
Object with this method. You do not need to specify this object.
expressionVariant
Specifies any Date expression.
vCDateVariant
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

See Also

Objects Overview

Related Topics

Abs | Asc | AscB | AscW | CBool | CByte | CCur | CDate | CDbl | CInt | CLng | CSng | CStr | ChrB | ChrW | Chr | Escape | Fix | Hex | Int | Oct | Sgn | UnEscape