2

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.

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
  • 1
    Did you try javacast(“string”, “12:00 AM”)? I use cast a lot to ensure that CF isn’t converting the value into something that I don’t really want. You may be able to use isvalid(“integer”) before casting to ensure that you aren’t converting number-like strings to text. – James Moberg Aug 08 '19 at 05:13

1 Answers1

2

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.

Saravana Kumar
  • 168
  • 1
  • 9