|
IsNumericDate
DescriptionEvaluates
whether a real number is a valid representation of a date (date/time object).
ReturnsTrue,
if the parameter represents a valid date/time object; False, otherwise.
Function syntaxIsNumericDate(number)
Parameters
Parameter
|
Description
|
number
|
A real number
|
UsageColdFusion,
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">
<p>Enter a value, and discover if 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>
|