Siebel VB Language Reference > VB Language Reference >

DateValue Function

This standard VB function returns a date value for the string specified.





A string representing a valid date


A variant of vartype 7 (date) that represents a date from January 1, 100, through December 31, 9999, where January 1, 1900, is 2.


DateValue accepts several different string representations for a date. It makes use of the operating system's international settings for resolving purely numeric dates. In contrast to the CVDate function (read CVDate Function), the argument to the DateValue function must be in a valid date format. If given a time in acceptable format, DateValue changes the time to 12:00:00 AM regardless of the value given. If given a number that is not an acceptable date or time format, DateValue returns a Type Mismatch error. For ways to display the desired result of a date conversion, read Format Function.


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

Sub Button_Click
   Dim str1 As String, answer As Integer, msgtext As String
   Dim nextweek
   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")
      msgtext = "Invalid date or format. Try again."
      Goto i
   End If
End Sub

See Also

DateSerial Function
Day Function
Format Function
Month Function
Now Function
TimeSerial Function
TimeValue Function
WebApplet_InvokeMethod Event
Year Function

Siebel VB Language Reference