View comments | RSS feed
Contents > CFML Reference > ColdFusion Functions > IsDate PreviousNext

IsDate

Determines whether a string or Java object can be converted to a date/time 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."

Date and time functions, Decision functions

IsDate(string)

CreateDateTime, IsNumericDate, LSDateFormat, LSIsDate, ParseDateTime

Parameter

Description

string

A string or a variable that contains one.

This function checks against U.S. date formats only. For other date support, see LSDateFormat.

A date/time object falls in the range 100 AD-9999 AD.

<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>

Contents > CFML Reference > ColdFusion Functions > IsDate PreviousNext

ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

Comments


spitch said on Oct 1, 2003 at 12:41 PM :
Slight differences to be aware of in 5.0 and 6.1 handling of IsDate.

Date 5.0 6.1
2 NO NO
a NO NO
2a YES YES
2 a YES YES
1/1/2 YES YES
1/1/20 YES YES
1/1/200 YES YES
1/1/2000 YES YES
1/1/2000 a NO NO
1/1/2000a NO YES
1/1/2000 2 NO NO
1/1/2000 2 a YES YES
1/1/2000 2a YES YES
1/1/20002a NO YES
SQL Datetime field does NOT like 6.1 dates like 1/1/2000a
spitch said on Oct 1, 2003 at 1:07 PM :
oops, typo above 1/1/2000 a is a date in 6.1
John2 said on Mar 17, 2004 at 3:11 AM :
what about an isdatetime() function?
ASandstrom said on May 9, 2005 at 11:06 AM :
Passing numeric data to the ColdFusion IsDate and ParseDateTime functions can yield unexpected results. For example, IsDate may return TRUE for numeric data that are not dates.
To work around this behavior, it is always advisable to only pass string data in a supported format to the IsDate and ParseDateTime functions, or, generate date-time data using the Now or CreateDate functions.
BoBNoT said on Aug 12, 2005 at 11:45 AM :
This code are incorect. It's necessary use the method="post" in <form>.
BoBNoT said on Aug 12, 2005 at 11:47 AM :
This code don't are functionaly, use the: method="post" in form. :P

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/funct128.htm