Siebel VB Language Reference > Methods Reference for Siebel VB > Date and Time Methods >

Convert Number to Date Method


The Convert Number to Date method converts an expression to the data type variant of type date. Note the following:

  • It returns a date variable type that represents a date from January 1, 100, through December 31, 9999. A value of 2 represents January 1, 1900.
  • It represents a time as fractional days.
  • It accepts string and numeric values.
  • It converts the time portion of a date expression in the following situations:
    • If you include a time portion as part of the expression.
    • If the time expression is the only argument.

To compare dates, you must make sure that you format these dates consistently with each other. You can use this method to convert both expressions before Siebel VB compares them.

For ways to display the desired result of a date conversion, see Set String Format Method.

For more information, see Variants.

Format

CVDate(expression)

The following table describes the arguments that you can use with this method.

Argument
Description

expression

Any expression that Siebel VB can evaluate to a number.

How the Operating System Affects the Date Format

The date format depends on the format that the operating system uses. For example, if the operating system uses the mm/dd/yyyy format, then the input argument must use the mm/dd/yyyy format or the mm-dd-yyyy format. If you use an integer value, then to calculate this date Siebel eScript adds this integer as the number of days after the year 1900. In this situation, it returns a date in the mm/dd/yyyy form.

Example

The following example displays the date for one week from a date that the user enters:

Sub Button_Click
      Dim str1 as String
   Dim nextweek
   Dim msgtext as String
i:
   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")
   Else
      Goto i
   End If
End Sub

Siebel VB Language Reference Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Legal Notices.