Siebel VB Language Reference > VB Language Reference >

CVDate Function

This standard VB function converts an expression to the data type variant of type date.





Any expression that can evaluate to a number


The value of expression expressed as a variant of vartype 7 (date).


CVDate accepts both string and numeric values.

The CVDate function returns a variant of vartype 7 (date) that represents a date from January 1, 100, through December 31, 9999. A value of 2 represents January 1, 1900. Times are represented as fractional days.

CVDate converts the time portion of a date expression if one is included as part of the expression, or if the time expression is the only argument. For ways to display the desired result of a date conversion, read Format Function.

When comparing dates, they must be formatted consistently. This can be achieved by using CVDate to convert both expressions before comparing them.


This example displays the date for one week from the date entered by the user.

Sub Button_Click
      Dim str1 as String
   Dim nextweek
   Dim msgtext as String
   str1 = "2/5/2001"
   answer = IsDate(str1)
   If answer = -1 then
      str1 = CVDate(str1)
      nextweek = DateValue(str1) + 7
      msgtext = "One week from the date entered is:
      msgtext = msgtext & "Format(nextweek,"dddddd")
      Goto i
   End If
End Sub

See Also

Asc Function
CCur Function
CDbl Function
Chr Function
CInt Function
CLng Function
CSng Function
CStr Function
CVar Function
DateValue Function
Format Function
Val Function

Siebel VB Language Reference