Forum Moderators: coopster

Message Too Old, No Replies

% in my database

         

franches

5:09 am on Oct 15, 2004 (gmt 0)

10+ Year Member



hi,
i was trying to insert in my database a number with % such as 20%. the fieldname is Status and set as double. i have a form wherein the user will input the percentage. however, in my database i've only seen the 20 and not 20%. how am i able to do it? any idea?

thanks

dmorison

5:18 am on Oct 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi franches,

The "double" data type (as with all numeric data types) is for storing a value only - it does not maintain any other characters that go with that value as far as your application is concerned, such a dollar sign or percentage.

If you actually want to see the percentage sign in your database you would need to use a character data type, such as varchar.

It is best stored as a numeric type (like you are using), and just have your application render the percent symbol whereever you display the number.

franches

5:36 am on Oct 15, 2004 (gmt 0)

10+ Year Member



why are you saying that it's better to set is as a double than a varchar?

jatar_k

5:40 am on Oct 15, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> It is best stored as a numeric type (like you are using), and just have your application render the percent symbol whereever you display the number.

since you know that col should have the % you can show it on the screen without storing it.

franches

6:16 am on Oct 15, 2004 (gmt 0)

10+ Year Member



thanks :)