Bookshelf Home | Contents | Index | Search | PDF |
Siebel VB Language Reference > Siebel VB Language Reference >
DateValue Function
This standard VB function returns a date value for the string specified.
Syntax
DateValue(date)
Returns
A variant of vartype 7 (date) that represents a date from January 1, 100, through December 31, 9999, where January 1, 1900, is 2.
Usage
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.
Example
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
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 SubSee Also
DateSerial Function
Day Function
Format Function
Month Function
Now Function
TimeSerial Function
TimeValue Function
WebApplet_InvokeMethod Event
Year Function
Bookshelf Home | Contents | Index | Search | PDF |
Siebel VB Language Reference Published: 18 June 2003 |