Siebel VB Language Reference > VB Language Reference >
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.
Dim str1 as String
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")