Information.IsDate Method
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Returns a Boolean value indicating whether an expression represents a valid Date value.
Namespace: Microsoft.VisualBasic
Assembly: Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)
Syntax
'Declaration
Public Shared Function IsDate ( _
Expression As Object _
) As Boolean
public static bool IsDate(
Object Expression
)
Parameters
- Expression
Type: System.Object
Required. Object expression.
Return Value
Type: System.Boolean
Returns a Boolean value indicating whether an expression represents a valid Date value.
Remarks
IsDate returns True if Expression is of the Date data type or can be converted to Date; otherwise, it returns False.
The Date 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.
Examples
The following example uses the IsDate function to determine if several variables represent valid Date 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.
Version Information
Silverlight
Supported in: 5, 4, 3
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
See Also