Whatever message this page gives is out now! Go check it out!

YesNoFormat

Last update:
May 18, 2026

Description

Evaluates a number or Boolean value.

Returns

Yes, for a non-zero value; No for zero, false, non-Boolean values, and an empty string ("" ).
The function throws an exception if you pass any string other than an empty string ("" ).
For example, YesNoFormat("Test") throws an exception.

Category

Syntax

YesNoFormat(value)

See also

IsBinaryIsNumeric

History

Member function added in ColdFusion (2016 release). For more information, see Member functions.

Parameters

Parameter
Description
value
A number, empty string, or a Boolean value.

Example

<cfscript>
       val1=1;
       WriteOutput(YesNoFormat(val1)); //Returns Yes
       val2=0;
       WriteOutput(YesNoFormat(val2)); //Returns No
       val3="1123";
       WriteOutput(YesNoFormat(val3)); //Returns Yes
       val4="No";
       WriteOutput(YesNoFormat(val4)); //Returns No
       val5=True;
       WriteOutput(YesNoFormat(val5)); //Returns Yes
       // try to return boolean value for non-empty string
       val6="hello";
       try{
             YesNoFormat(val6);
       }
       catch (any e){
             WriteOutput(e.message); //Displays: cannot convert the value "hello" to a boolean 
       }
</cfscript>

Using member function

<cfscript>
       val=True;
       WriteOutput(val.YesNoFormat());
</cfscript>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page