• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

price range

Hi,

Please, tell me if I am wrong.

in my form I have two text fields for price range.

from
to

in my database I have price of 999.99
if I put in my form this

from: 0
to:     1000

I don't get anything

but if I put

from: 0
to:  10000

I do see the record.

In my database PRICE is defined as "varchar(50)"



In my query I have it like this: 

AND 
(
(ADS.Price >= #(session.PriceFromCT)# AND ADS.Price <= #(session.PriceToCT)#)
)

please, tell me what I am doing wrong?

why do I have to put 
10000 to get my record price of 999.99

Open in new window

0
lulu50
Asked:
lulu50
  • 4
  • 4
1 Solution
 
VipulKadiaCommented:
You have to cast your column at the time of comparision.
Following is a MS-SQL syntax to convert a column in to NUMERIC.

CAST(yourColumn as NUMERIC(18,4))
0
 
lulu50Author Commented:
I have it cast as this:

CONCAT('$', Cast(ADS.price AS DECIMAL(5,2))) AS 'price'

is it wrong to be decimal?

0
 
VipulKadiaCommented:
No. Even decimal is also fine.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
lulu50Author Commented:
If I do this

CONCAT( '$', Cast( ADS.price AS NUMERIC( 18, 4 ) ) ) AS 'price',

I get an error in MySQL
0
 
VipulKadiaCommented:
Try following :

CONCAT( '$', Cast( ADS.price AS DECIMAL( 18, 4 ) ) ) AS 'price',

0
 
lulu50Author Commented:
in my database price is like this:

price
88888

on my site the same record display price like this
CONCAT( '$', Cast( ADS.price AS DECIMAL( 18, 4 ) ) ) AS 'price',

$88888.0000

how can I change $88888.0000
to this: $88888.00
0
 
Pratima PharandeCommented:
CONCAT( '$', Cast( ADS.price AS DECIMAL( 18, 2 ) ) ) AS 'price',
0
 
VipulKadiaCommented:
CONCAT( '$', Cast( ADS.price AS DECIMAL( 18, 2 ) ) ) AS 'price'
0
 
lulu50Author Commented:
Thank you
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now