July 15, 2004 at 10:44 am
1, len(convert(varchar(20), cast(projectcost as money), 1)) - 3)
July 15, 2004 at 2:26 pm
This was a challenge...
Couldn't find many ways to do it better :-).
But this is shorter ;-), and will round the float value correctly:
declare @projectcost float
set @projectcost = 6842332198.523549
-- shorter version with correct rounding
select substring(convert(varchar(20),cast(str(@projectcost) as money),1),1,1+4*(len(convert(bigint,@projectcost))-1)/3)
-- marginally longer version
select substring(convert(varchar(20),cast(@projectcost as money),1),1,len(convert(varchar(20),cast(@projectcost as money),1))-3)
/rockmoose
You must unlearn what You have learnt
July 15, 2004 at 2:27 pm
That should be Client side Responsibility.
Just my opinion
* Noel
July 15, 2004 at 3:21 pm
And a very good opinion noeld, agree.
Don't format until the data is presented to the user.
/rockmoose
You must unlearn what You have learnt
July 16, 2004 at 1:58 am
I'm getting this as xml and transforming using xslt. If someone can show me how to do the formatting in xslt that would be cool.
July 16, 2004 at 3:53 am
whew - only 5 mins to open this page! sites a bit slow for me at the mo
you can use the format-number function - something like
<xsl:value-of select="format-number(mynumber, '#,###')" />
maybe the round function as well
zvon.org has a really good xslt reference
http//www.zvon.org/xxl/XSLTreference/Output/index.html
jt
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply