isNumericDate
Description
Evaluates whether a real number is a valid representation of a date (date/time object).
Categories
Related
Syntax
IsNumericDate(number)
Attributes
| Attribute | Description | Required | Default |
|---|---|---|---|
| number | A real number |
Returns
True,
if the parameter represents a valid date/time object; False, otherwise.
Usage
ColdFusion, by default, evaluates any input parameter and attempts to convert it to a real number before it passes the parameter to the IsNumericDate function. As a result, parameter values such as 12/12/03 and {ts '2003-01-14 10:04:13'} return True, because ColdFusion converts valid date string formats to date/time objects, which are real numbers.
Example
<h3>IsNumericDate Example</h3>
<cfif IsDefined("form.theTestValue")>
<!--- test if the value represents a number or a pre-formatted Date value --->
<cfif IsNumeric(form.theTestValue) or IsDate(form.theTestValue)>
<!--- if this value is a numericDate value, then pass --->
<cfif IsNumericDate(form.theTestValue)>
<h3>The string <cfoutput>#DE(form.theTestValue)#</cfoutput> can be converted to a valid numeric date</h3>
<cfelse>
<h3>The string <cfoutput>#DE(form.theTestValue)#</cfoutput> can not be converted to a valid numeric date</h3>
</cfif>
<cfelse>
<h3>The string <cfoutput>#DE(form.theTestValue)#</cfoutput> is not a valid numeric date</h3>
</cfif>
</cfif>
<form action="#cgi.script_name#" method="POST">
Enter a value, and discover if it can be evaluated to a date value.
<input type="Text" name="TheTestValue" value="<CFOUTPUT>#Now()#</CFOUTPUT>">
<input type="Submit" value="Is it a Date?" name="">
</form>