IsDate(expression) tests whether VBScript can interpret a value as a date or time. It is useful when reading uncertain values, but a successful result does not prove that an ambiguous input means the date the user intended.
<%
Dim enteredDate
enteredDate = DateSerial(2007, 2, 28)
Response.Write IsDate(enteredDate)
%>
Output: True. The value is already a valid Date object.
IsDate(expression)
The function returns the Boolean value True when the expression can be recognized as a date/time and False otherwise. IsDate() uses the current locale when interpreting text.
<%
Dim my_date
my_date = "February 29, 2007"
Response.Write IsDate(my_date)
%>
Output in an English locale: False; 2007 was not a leap year.
<%
Response.Write IsDate(DateSerial(2024, 2, 29)) & "<br>"
Response.Write IsDate("February 29, 2023")
%>
The first result is True. Under an English locale, the second is False. A genuine Date object is more reliable than free-form text.
<%
Dim previousLocale
previousLocale = SetLocale(1033) ' English (United States)
Response.Write IsDate("12/31/2024")
SetLocale previousLocale
%>
Output in a US English locale: True. A string such as 02/03/2026 could be February 3 or March 2 under different regional settings.
DateSerial(), and compare the returned Year(), Month() and Day() with the input. IsDate() alone is not enough.<%
Dim valueText, parsedDate
valueText = "December 25, 2026"
If IsDate(valueText) Then
parsedDate = CDate(valueText)
Response.Write Year(parsedDate) & "-" & Month(parsedDate) & "-" & Day(parsedDate)
Else
Response.Write "Please enter a valid date"
End If
%>
The textual month name requires a compatible locale. For stricter validation, prefer an unambiguous numeric input structure.
<%
Dim y, m, d, valueDate, validDate
y = 2026: m = 2: d = 31
validDate = False
If y >= 1000 And y <= 9999 And m >= 1 And m <= 12 And d >= 1 And d <= 31 Then
valueDate = DateSerial(y, m, d)
validDate = (Year(valueDate) = y And Month(valueDate) = m And Day(valueDate) = d)
End If
Response.Write validDate
%>
False
<%
Dim rawDate
rawDate = Trim(Request.Form("date_value"))
If Len(rawDate) = 0 Then
Response.Write "Enter a date"
ElseIf IsDate(rawDate) Then
Response.Write "Recognized by the current server locale"
Else
Response.Write "Not recognized as a date"
End If
%>
This example demonstrates the function, but do not accept arbitrary locale-dependent text as a canonical date in an application that requires one precise input format.
Testing the output of DateSerial() with IsDate() will not catch overflow because DateSerial() normalizes dates. Also, IsDate() does not check whether a date falls within a business rule such as minimum age or booking date.
Not necessarily. Parsing is influenced by locale and supported date formats. For an exact format, parse and validate its numeric components.
No. DateSerial() normalizes components first. Compare the created date’s parts against the inputs.
Yes. It can recognize some valid time expressions as well as dates.
See the complete ASP date-input validator.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.