Siebel VB Language Reference > VB Language Reference >

Date Statement


This standard VB function sets the computer's date.

Syntax

Date[$] = expression

Argument
Description

expression

A string in one of the following forms:

  • mm-dd-yy
  • mm-dd-yyyy
  • mm/dd/yy
  • mm/dd/yyyy

In the preceding string forms, the placeholders are interpreted as follows:

Placeholder
Meaning

mm

A month expressed as a two-digit number (01 to 12)

dd

A day expressed as a two-digit number (01 to 31)

yy

A year expressed as a two-digit number (00 to 99)

yyyy

A year expressed as a four-digit number (1980 to 2099)

Returns

Not applicable

Usage

If the dollar sign ($) is omitted, expression can be a string containing a valid date, a variant of vartype 7 (date), or a variant of vartype 8 (string).

If expression is not already a variant of vartype 7 (date), Date attempts to convert it to a valid date from January 1, 1980, through December 31, 2099. Date uses the Short Date format in the International section of Windows Control Panel to recognize day, month, and year if a string contains three numbers delimited by valid date separators. In addition, Date recognizes month names in either full or abbreviated form.

Example

This example changes the computer's date to a date entered by the user.

Sub Button_Click
   Dim userdate
   Dim answer
i:
   userdate = "2/5/2001"
   If userdate = "" then
      Exit Sub
   End If
   answer = IsDate(userdate)
   If answer = -1 then
      Date = userdate
   Else
      Goto i
   End If
End Sub

Related Topics

Date Function
Time Function
Time Statement

Siebel VB Language Reference Copyright © 2006, Oracle. All rights reserved.