Editare

Partajați prin


Information.IsDate(Object) Method

Definition

Returns a Boolean value indicating whether an expression represents a valid Date value.

public:
 static bool IsDate(System::Object ^ Expression);
public static bool IsDate (object? Expression);
public static bool IsDate (object Expression);
static member IsDate : obj -> bool
Public Function IsDate (Expression As Object) As Boolean

Parameters

Expression
Object

Required. Object expression.

Returns

Returns a Boolean value indicating whether an expression represents a valid Date value.

Examples

The following example uses the IsDate function to determine if several variables represent valid DateTime values.

Dim firstDate, secondDate As Date
Dim timeOnly, dateAndTime, noDate As String
Dim dateCheck As Boolean
firstDate = CDate("February 12, 1969")
secondDate = #2/12/1969#
timeOnly = "3:45 PM"
dateAndTime = "March 15, 1981 10:22 AM"
noDate = "Hello"
dateCheck = IsDate(firstDate)
dateCheck = IsDate(secondDate)
dateCheck = IsDate(timeOnly)
dateCheck = IsDate(dateAndTime)
dateCheck = IsDate(noDate)

In the preceding example, IsDate returns True for the first four calls and False for the last call.

Remarks

IsDate returns True if Expression is of the DateTime data type or can be converted to it; otherwise, it returns False.

The DateTime data type holds both a date value and a time value. IsDate returns True if Expression represents a valid date, a valid time, or a valid date and time.

Applies to

See also