May 18, 2013 at 12:02 am
Dear,
My client requires to add a hyphen(-) in lieu of comma(,) in the field of amount. But client requires only one hyphen(-) in the amount. For example, Total price is 10,000,000 but new requirement is 10-000000.
Say if I execute "select amount from mytable". The result is '10-000000'. Here I need to do some formatting. But I have no idea.
Please help me to sort out the problem.
Rgds,
Akbar
May 18, 2013 at 2:41 am
normally formatting is better left to the front end app to perform.
sometimes however this isn't always poss or desired.....
so in this case, how does your client want the following displayed?
-10,000,000
1
10
100
1,000
10,000
100,000
1,000,000
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
May 18, 2013 at 7:28 am
There is always solution for a particular case. But what about cases without any commas?
Here is one proposal:
declare @amt varchar(20)
set @amt = '10,000,000.00'
--desired is 10-000000.00
set @amt = substring(replace(@amt,',','-'),1,charindex('-',replace(@amt,',','-'),1))+substring(replace(@amt,',',''),charindex('-',replace(@amt,',','-'),1),len(replace(@amt,',',''))-(charindex(replace(@amt,',','-'),'-',1)))
print @amt
IgorMi
Igor Micev,My blog: www.igormicev.com
May 18, 2013 at 6:19 pm
shohelr2003 (5/18/2013)
Dear,My client requires to add a hyphen(-) in lieu of comma(,) in the field of amount. But client requires only one hyphen(-) in the amount. For example, Total price is 10,000,000 but new requirement is 10-000000.
Say if I execute "select amount from mytable". The result is '10-000000'. Here I need to do some formatting. But I have no idea.
Please help me to sort out the problem.
Rgds,
Akbar
No reflection on you, Akbar.
That's one of the oddest formatting requirements I've ever seen for numeric values. Why on Earth does the client need it that way?
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply