Syntax |
CDate(expression) CVDate(expression) |
Description |
Converts expression to a date, returning a Date value. |
Comments |
The expression parameter is any expression that can be converted to a Date. A runtime error is generated if expression is Null. If expression is a String, an attempt is made to convert it to a Date using the current country settings. If expression does not represent a valid date, then an attempt is made to convert expression to a number. A runtime error is generated if expression cannot be represented as a date. These functions are sensitive to the date and time formats of your computer. The CDate and CVDate functions are identical. |
Example |
This example takes two dates and computes the difference between them. Sub Main() Dim date1 As Date date1 = CDate(#1/1/1994#) date2 = CDate("February 1,
1994") MsgBox "The date difference is " & CInt(diff) & " days." End Sub |
See Also |
CCur (function); CBool (function); CDbl (function); CInt (function); CLng (function); CSng (function); CStr (function); CVar (function); CVErr (function); Date (data type). |
C |