'Fraid not. Informix allows either. Thanks for the suggestion though!
Main Topics
Browse All TopicsHi, I have a query which I want to go something like:
select fw_year
from table
where fw_year[1,4] between 2002 and 2007
and fw_year <> "BLAH"
The fw_year column contains values like "2001/2002", "2002/2003" and one special value "BLAH". Currently, despite my exclusion of "BLAH" in the filter, I get a "Character to numeric conversion error" when trying to do a numeric comparison. Is there a function to convert my year value to numeric for the comparison?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I would suggest putting the "BLAH" condition first, then putting the numbers in double quotes, (effectively making them characters.) "2002" is still less than "2007" even if they are characters, so the following query should work
select fw_year
from table
and fw_year <> "BLAH"
and fw_year[1,4] between "2002" and "2007"
Good luck
That did work (will give you some points for it), but unfortunately I was intending to expand the SQL to something like this:
select fw_year
from table
where fw_year[1,4] between (year(current)-5) and year(current)
and fw_year <> "BLAH"
which I don't think can work with that technique. Oracle has a function to_number which would do what I want, but I can't seem to find an informix equivalent.
I may be able to create a stored procedure to do it, and convert the value with a LET, as suggested here:
http://www.dbforums.com/ar
the same page suggests a cast too, but that doesn't seem to work in my case. It makes me think the database engine is trying to convert the value "BLAH" to a number despite being excluded - I guess it would depend on which order the query optimizer chooses to apply the filters. I know you can give hints to the query optimizer, but I'm not sure I want to go there!
Business Accounts
Answer for Membership
by: BillBachPosted on 2007-12-13 at 20:51:19ID: 20469805
I'm not as familiar with Informix, but most SQL compilers use 'single quotes' to delineate strings, and "double-quotes" to indicate a way to bypass the SQL parser (for using odd field names like "Select"). Could it be as simple as changing "BLAH" to 'BLAH'?