Author |
Topic |
Debugger
Starting Member
4 Posts |
Posted - 2008-02-09 : 02:58:11
|
Gurus:I have a float value.. 2343433.33. want to convert into thousand separator (like 2,343,433.33). To do so i am writing writing a function, as i couldn't find any.When converted value into string, removes .33 value.can you tell me which function should i use to get float value, with .33 in it? |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-09 : 03:03:49
|
I think this should be for a front end requirement and would be best to do it at front end rather than in SQL. which front end are you using? There are numerous functions available which enables you to these formatting easily at front end. |
 |
|
Debugger
Starting Member
4 Posts |
Posted - 2008-02-09 : 03:17:12
|
thanks visakh16.Requirement is to post it into mobile messaging, and unfortunately there isn't any front like vb in this case. Any idea to do it. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-09 : 03:48:08
|
How you tried to convert to string? did you try using CONVERT()? |
 |
|
Debugger
Starting Member
4 Posts |
Posted - 2008-02-09 : 04:09:39
|
if we take it as procedure:quote: Create procedure str_float2(@val2 as float) asdeclare @str1 as varchar(30),@int1 as integerset @str1 = convert(varchar(30), @val2)print @str1set @int1 = @val2print @val2exec str_float2 2343433.33Result:2.34343e+006 [varchar]2.34343e+006 [integer]
|
 |
|
Debugger
Starting Member
4 Posts |
Posted - 2008-02-09 : 04:22:22
|
CorrectionCreate procedure str_float2(@val2 as float) asdeclare @str1 as varchar(30),@int1 as integerset @str1 = convert(varchar(30), @val2)print @str1set @int1 = @val2print @int1exec str_float2 2343433.33Result:2.34343e+006 [varchar]2343433 [integer]
quote: Originally posted by Debugger if we take it as procedure:quote: Create procedure str_float2(@val2 as float) asdeclare @str1 as varchar(30),@int1 as integerset @str1 = convert(varchar(30), @val2)print @str1set @int1 = @val2print @val2exec str_float2 2343433.33Result:2.34343e+006 [varchar]2.34343e+006 [integer] |
 |
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2008-02-09 : 09:58:28
|
I can't beleive I am posting this, but...declare @f floatset @f=2343433.33select convert(varchar,convert(decimal(20,2), @f)) elsasoft.org |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-11 : 05:09:06
|
quote: Originally posted by jezemine I can't beleive I am posting this, but...declare @f floatset @f=2343433.33select convert(varchar,convert(decimal(20,2), @f)) elsasoft.org
Is this what you wanted to post?declare @f floatset @f=2343433.33select convert(varchar,convert(money, @f),1)MadhivananFailing to plan is Planning to fail |
 |
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2008-02-11 : 08:55:18
|
that works too. i just don't like the idea of returning a numeric type as a string generally, hence the reluctance. elsasoft.org |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-11 : 09:19:32
|
<< i just don't like the idea of returning a numeric type as a string generally>>I too MadhivananFailing to plan is Planning to fail |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-02-11 : 09:23:19
|
Me three... E 12°55'05.25"N 56°04'39.16" |
 |
|
|