Link to home
Start Free TrialLog in
Avatar of slick_moe
slick_moe

asked on

Coldfusion - how to determine if number in ValueList() is within a specified range

How do I go about taking a valuelist such as (1, 5, 12, 18) and running a function to determine if any of the values in the list are within a specified range.  For example, if the range was from 2 to 6, I need an output that would that would state that the valuelist DOES have a value in that range, which is 5 in this example.

<cfset mylist= ValueList(myquery.ids,",")>
Now I need something like <cfif a value in mylist is between 2 and 6>Value exists</cfif>
SOLUTION
Avatar of gdemaria
gdemaria
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
both code samples posted so far are good ones, but if you let us know your reason for this, we might come up with yet another example, which may be suited better to your purpose...

i.e. depending on the size of your list, and the range you are checking for, it may be more efficient to just run a QoQ on your original query to select IDs that fall within your range, instead of looping over list/range...

Azadi
Just to let you know gdemaria's answer is correct.
Slick_moe, choose whatever fits your needs, they both are correct. Not sure where Nathans (the non-expert) comment is coming from...
Real simpleZadoc I was one of the past experts top of the charts here and have not been back for a while.  He asked for a FUNCTION.  I understand your answer will work but it is not a FUNCTION.  I have been doing ColdFusion for a VERY long time.  If you guys had NOT answered correctly I would have posted a answer.  Sorry if I offended you but I do not like questions hanging around that have a legitimate answer that is correct for the question asked.  So instead of providing a new answer I simply made sure to tell the person asking the question to please accept it.  If the answer was incomplete and you gave a more complete answer I would have explained that.  I appreciated you trying.  If you want to check and see http://www.linkedin.com/in/nathanstanford here is my work record to show I am an expert in ColdFusion.
So if he asked for a function, Gdemaria's answer is a function.. You really think he needs your help determining which one is a function?

Sorry I offended you. You are an expert.

I don't feel your comment was appropriate and it was extremely vague.
Also Nathans... you spelt "Verision" wrong on your Linkedin profile.

Its     Verizon
Avatar of slick_moe
slick_moe

ASKER

I just have to say that gdemaria's answer is a "function," which is what I asked for.  I wasn't after a "function" per se, only code that would give the functionality I needed.  It's my fault for not being more clear.  Being more of a novice, Zadoc's answer worked perfectly for my needs and so get's the most points.  Some points also to gdemaria for a great answer as well.  Thanks to all!