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

Convert String to Date Method


The Convert String to Date method converts a string to a date. It returns a date variable type that represents a date from January 1, 100, through December 31, 9999, where January 1, 1900, is 2. For more information, see Variants. Note the following:

  • It accepts multiple string representations for a date.
  • It uses the international settings of the operating system to resolve a numeric date.
  • Because this method handles dates and not times, if it receives time information then it modifies this time to 12:00:00 AM, which is midnight of the date value.

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

Format

DateValue(date)

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

Argument
Description

date

Any numeric or string expression that can evaluate to a date and time or date value. This value can be of any type, including string.

If the value that the date argument contains is not in a valid date format, then this method returns a Type Mismatch error.

Using the DateValue Statement With the GetFormattedFieldValue Statement

To avoid a locale conflict, it is recommended that you do not use the DateValue statement together with the GetFormattedFieldValue statement. Note the following:

  • The GetFormattedFieldValue statement formats a date according to the locale setting of the object manager.
  • The DateValue statement expects a date string in a format according to the locale setting of the operating system.
  • A Siebel Server can run multiple object managers with different language settings. For example, ENU, DEU, or FRA. However, the server operating system can only have one value selected for Regional Options, such as English (United States).

In this example, if a client connects to a DEU object manager on a Siebel Server where the Regional Options parameter is set to English (United States), then the GetFormattedFieldValue statement returns a string that contains a date that it formats for DEU, but the DateValue statement expects a string formatted for ENU. This situation results in the following error in Siebel VB:

Illegal Function Call

Example

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

Sub Button_Click
   Dim str1 As String, answer As Integer, msgtext As String
   Dim nextweek
i:
   str1 = "12/22/2000"
   answer = IsDate(str1)
   If answer = -1 then
      str1 = CVDate(str1)
      nextweek = DateValue(str1) + 7
      msgtext = "One week from your date is: "
      msgtext = msgtxt & Format(nextweek,"dddddd")
   Else
      msgtext = "Invalid date or format. Try again."
      Goto i
   End If
End Sub

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