IsDate

Description

Returns 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." See the Usage section for crucial information.

Category

Decision functions

Syntax


IsDate(string) 

See also

ParseDateTime, CreateDateTime, IsNumericDate

Parameters

Parameter
Description
string
A string value

Usage

IsDate checks only the U.S. date format. For other date support, see LSDateFormat.

Year values 0-29 are interpreted as 21st century dates. Year values 30-99 are interpreted as 20th century dates.

Example

<!--- This example shows the use of IsDate --->

<html>

<head>

<title>IsDate Example</title>

</head>

<body bgcolor = silver>

<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" method = "POST">

<P>Enter a string, determine 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>

</body>

</html>



Banner.Novgorod.Ru