IsDate

Description

Determines whether a string or Java object can be converted to a date/time value.

Return value

True, if string can be converted to a date/time value; otherwise, False. ColdFusion converts the Boolean return value to its string equivalent, "Yes" or "No."

Category

Date and time functions, Decision functions

Syntax

IsDate(string) 

See also

CreateDateTime, IsNumericDate, LSDateFormat, LSIsDate, ParseDateTime

Parameters

Parameter Description
string
A string or a variable that contains one.

Usage

This function checks only a U.S. date format. For other date support, see LSDateFormat.

A date/time object falls in the range 100 AD-9999 AD. See "How ColdFusion processes two-digit year values".

Example

<h3>IsDate Example</h3>
<cfif IsDefined("FORM.theTestValue")>
  <cfif IsDate(FORM.theTestValue)>
  <h3>The string <cfoutput>#DE(FORM.theTestValue)#</cfoutput> 
   is a valid date</h3>
  <cfelse>
  <h3>The string <cfoutput>#DE(FORM.theTestValue)#</cfoutput> 
   is not a valid date</h3>
  </cfif>
</cfif>
<form action = "isDate.cfm">
<p>Enter a string, find whether it can be evaluated to a date value.
<p><input type = "Text" name = "TheTestValue" value = "<cfoutput>#Now()#
</cfoutput>">
<input type = "Submit" value = "Is it a Date?" name = "">
</form>

Comments