User Guide Cancel

IsDate

 

Description

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

Returns

True, if string can be converted to a date/time value; False, otherwise.

Category

Syntax

IsDate(string)
IsDate(string)
IsDate(string)

See also

Parameters

Parameter

Description

string

A string or a variable that contains one.

Usage

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.

Example

<cfscript>
writeOutput("True, if string can be converted to a date/time value; False, otherwise. ColdFusion converts the Boolean return value to its string equivalent, Yes or No" & "<br>" & "<br>")
date = IsDate(now());
writeOutput("Can string be converted to a date/time value : " & date & "<br>");
string = IsDate("12/12/2018");
writeOutput("Can 12/12/2018 be converted to a date/time value: " & string & "<br>");
string = IsDate("Hello_world");
writeOutput("Can Hello_world be converted to a date/time value: " & string);
</cfscript>
<cfscript> writeOutput("True, if string can be converted to a date/time value; False, otherwise. ColdFusion converts the Boolean return value to its string equivalent, Yes or No" & "<br>" & "<br>") date = IsDate(now()); writeOutput("Can string be converted to a date/time value : " & date & "<br>"); string = IsDate("12/12/2018"); writeOutput("Can 12/12/2018 be converted to a date/time value: " & string & "<br>"); string = IsDate("Hello_world"); writeOutput("Can Hello_world be converted to a date/time value: " & string); </cfscript>
<cfscript>
    writeOutput("True, if string can be converted to a date/time value; False, otherwise. ColdFusion converts the Boolean return value to its string equivalent, Yes or No" & "<br>" & "<br>")
    date = IsDate(now());
    writeOutput("Can string be converted to a date/time value : " & date & "<br>");
    string = IsDate("12/12/2018");
    writeOutput("Can 12/12/2018 be converted to a date/time value: " & string & "<br>");
    string = IsDate("Hello_world");
    writeOutput("Can Hello_world be converted to a date/time value: " & string);
</cfscript>

Output

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

Can string be converted to a date/time value : YES
Can 12/12/2018 be converted to a date/time value: YES
Can Hello_world be converted to a date/time value: NO

Get help faster and easier

New user?