This works for a select:

declare @myTest varchar(10)
set @myTest = '7/8"'

select (cast(left(@myTest, charindex('/', @myTest) - 1) as float) /
        cast(right(replace(@myTest, '"', ''), len(replace(@myTest, '"', ''))
- charindex('/', @myTest)) as float) )

So your where would be:

WHERE 0=0
AND ((cast(left(@myTest, charindex('/', @myTest) - 1) as float) /
        cast(right(replace(@myTest, '"', ''), len(replace(@myTest, '"', ''))
- charindex('/', @myTest)) as float)) between #Form.width1# and
#form.width2#))

Of course this assumes that you have MS SQL.

I tested the where with the select above and different values.  It worked
fine.

You should also note that the " had to be stripped out to make the
comparison, if the " isn't actualy in your database, the formula can be
simplified.

Steve


-----Original Message-----
From: Che Vilnonis [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 13, 2003 3:57 PM
To: CF-Talk
Subject: I sent this before and got no response...maybe someone can
help?


In my db I've got a varchar column called 'width'.
It has values like 3/4" or 5/8", etc.

I'd like to write a where clause in a SQL query that does
something like this:

----------
WHERE 0=0
AND (WIDTH BETWEEN #FORM.Width1# AND #FORM.Width2#)
[i.e. -- (AND (0.75 BETWEEN 0.5 AND 1))]
----------

What do I need to do to make this work? Convert? Cast?
I don't know how to make SQL convert 7/8" into 0.875.

Che Vilnonis
Application Developer
Advertising Systems Incorporated
8470C Remington Avenue
Pennsauken, NJ 08110
p: 856.488.2211
f: 856.488.1990
www.asitv.com

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
http://www.cfhosting.com

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to