IsDate() function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Could someone give me an example of the IsDate() function. I need it to find
out if text in a record is a date or not. Thanks.
 
A simple search (using the wizard in the 'build expression' dialog) brought
up the following. Next time check the built in help first; you'll get your
answers more quickly.

Returns a Boolean value indicating whether an expression can be converted to
a date.

Syntax

IsDate(expression)

The required expression argument is a Variant containing a date expression
or string expression recognizable as a date or time.

Remarks

IsDate returns True if the expression is a date or can be converted to a
valid date; otherwise, it returns False. In Microsoft Windows, the range of
valid dates is January 1, 100 A.D. through December 31, 9999 A.D.; the ranges
vary among operating systems.


The following example prompts the user for a string value, uses the IsDate
function to determine whether the string can be converted to a date, and then
displays an appropriate message.

Sub CheckDate()
Dim strDate As String

strDate = InputBox("Enter string to display as a date.")
' Test variable.
If IsDate(strDate) Then
' If string is date, format and display in dialog.
MsgBox "The date is: " & Format(DateValue(strDate), "Long Date")
Else
MsgBox "The value you entered is not a date."
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top