Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 money format ..need some help..please

Author  Topic 

a4nsd
Starting Member

20 Posts

Posted - 2007-01-12 : 22:57:21
Hi everybody.
Here's my Product fields

ID int,
Title nvarchar(50),
Price money

How can I get value from price field like this
IF PRICE is 12,000.00 it will display 12,000
IF PRICE is 12,234.34 it will display 12,234.34

Thanks very much...I am a beginner. Sorry for foolish question

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-01-13 : 04:48:46
[code]
select value, replace(convert(varchar(20), value, 1), '.00', '')
from (
select convert(money, 12000) as value union all
select convert(money, 12234.34) as value
) v
[/code]

You might also want to consider doing the formatting in your front end application


KH

Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2007-01-13 : 06:23:29
quote:
Originally posted by khtan
[br
You might also want to consider doing the formatting in your front end application


KH






I agree with that.

Also, take note. No question is "FOOLISH" Per se. Its a learning process
Go to Top of Page

a4nsd
Starting Member

20 Posts

Posted - 2007-01-13 : 21:03:38
Thanks khtan for your reply.That is only two of my example. But when I have more than 2 records in my database. How can I get ?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-01-14 : 02:09:01
[code]
select value, replace(convert(varchar(20), value, 1), '.00', '')
from yourtable
[/code]



KH

Go to Top of Page
   

- Advertisement -