For Programmers: Free Programming Magazines  


Home > Archive > MSDN > March 2004 > Re: How to transform/convert a numeric var into char with format like 999,999,999.99?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: How to transform/convert a numeric var into char with format like 999,999,999.99?
E Zapata

2004-03-28, 10:07 pm

On Tue, 16 Mar 2004 02:31:05 -0800, "simon"
<anonymous@discussions.microsoft.com> wrote:

>i.e. transform 12345678.12 --> 12,345,678.12 for printing purpose
>Thanks in advance!
>Simon



I think you're looking for GetNumberFormat().
Bryan Martin

2004-03-28, 10:07 pm

How did you come to that conclusion given the OP didnt specify what language
he was using?

"E Zapata" <user@invalid.domain> wrote in message
news:836e50lo2r5t2e3tg4r9ea0ukcauipdfi2@
4ax.com...
> On Tue, 16 Mar 2004 02:31:05 -0800, "simon"
> <anonymous@discussions.microsoft.com> wrote:
>
>
>
> I think you're looking for GetNumberFormat().



Saga

2004-03-28, 10:07 pm

I think it's what's called a shot in the dark!

Here is mine for VB:

format$(1235678.12,"Standard")


"Bryan Martin" <uce@ftc.gov> wrote in message
news:ew%23sws3CEHA.712@tk2msftngp13.phx.gbl...
> How did you come to that conclusion given the OP didnt specify what

language
> he was using?
>
> "E Zapata" <user@invalid.domain> wrote in message
> news:836e50lo2r5t2e3tg4r9ea0ukcauipdfi2@
4ax.com...
>
>



Simon

2004-03-28, 10:08 pm

Thanks & Sorry! The language I'm using is Transact-SQL.
Kizzy

2004-03-28, 10:08 pm

Don't know if it is sufficiently robust for your problem, but you can cast
as money and convert:

DECLARE @myval as decimal(10,2)
SET @myval = 12345678.12
SELECT CONVERT(varchar,CAST(@myval AS money),1)

------------------------------
12,345,678.12

or simply:

SELECT CONVERT(varchar,CAST(12345678.12 AS money),1)

------------------------------
12,345,678.12

Works for SQL SVR, anyway.

"E Zapata" <user@invalid.domain> wrote in message
news:836e50lo2r5t2e3tg4r9ea0ukcauipdfi2@
4ax.com...
> On Tue, 16 Mar 2004 02:31:05 -0800, "simon"
> <anonymous@discussions.microsoft.com> wrote:
>
>
>
> I think you're looking for GetNumberFormat().



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com