James A Mohler
James A Mohler

Reputation: 11120

Dates not equal to numbers

I don't want this to be true

<cfset somedata = "12:00 AM">

<cfif "12:00 AM" EQ 0>
    Wow
</cfif>

Most of the time somedata has numbers. But it can have time. If it has 12:00 AM, I don't want this if statement to return as true.

Upvotes: 2

Views: 104

Answers (1)

Saravana Kumar
Saravana Kumar

Reputation: 178

You can use code like below ( Add condition isNumeric(somedata)), It will check somedata EQ 0 condition only when the somedata is numeric.

<cfset somedata = "12:00 AM">

<cfif isNumeric(somedata) AND somedata EQ 0>
    Wow
</cfif>

For your scenario ( somedata = "12:00 AM" ) somedata is not numeric, so that time ( isNumeric(somedata) ) condition will failed. It will not go under if condition.

Upvotes: 2

Related Questions