 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Peet Koekemoer Guest
|
Posted: Tue Jun 07, 2005 11:40 am Post subject: How to Format a String |
|
|
Good day all,
I'm using MSSQL2000
I would like to know how do I format a string in SQL:
The result must look like this:
1,000,000.00
and NOT like this
1000000.00
This is my Query I currently use:
Field:
[Budget_Cost] Numeric(18,2)
Select
Budget_Cost
from
Sysset
Thanx,
Peet
|
|
| Back to top |
|
 |
Mike Shkolnik Guest
|
Posted: Tue Jun 07, 2005 1:11 pm Post subject: Re: How to Format a String |
|
|
Just define the DisplayFormat property for your field in Delphi:
#,#.00
--
With best regards, Mike Shkolnik
EMail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
http://www.scalabium.com
"Peet Koekemoer" <peetmce (AT) telkomsa (DOT) net> wrote
| Quote: | Good day all,
I'm using MSSQL2000
I would like to know how do I format a string in SQL:
The result must look like this:
1,000,000.00
and NOT like this
1000000.00
This is my Query I currently use:
Field:
[Budget_Cost] Numeric(18,2)
Select
Budget_Cost
from
Sysset
Thanx,
Peet
|
|
|
| Back to top |
|
 |
treok Guest
|
Posted: Tue Jun 07, 2005 2:32 pm Post subject: Re: How to Format a String |
|
|
| Quote: | Good day all,
I'm using MSSQL2000
I would like to know how do I format a string in SQL:
The result must look like this:
1,000,000.00
and NOT like this
1000000.00
This is my Query I currently use:
Field:
[Budget_Cost] Numeric(18,2)
Select
Budget_Cost
from
Sysset
Thanx,
Peet
|
Something like this:
select Budget_Cost,
case len(convert(varchar(10),Budget_Cost))
when 7 then substring(convert(varchar(20),Budget_Cost),1,1) + ',' +
substring(convert(varchar(20),Budget_Cost),2,len(convert(varchar
(20),Budget_Cost)))
when 8 then substring(convert(varchar(20),Budget_Cost),1,2) + ',' +
substring(convert(varchar(20),Budget_Cost),3,len(convert(varchar
(20),Budget_Cost)))
when 9 then substring(convert(varchar(20),Budget_Cost),1,3) + ',' +
substring(convert(varchar(20),Budget_Cost),4,len(convert(varchar
(20),Budget_Cost))
when 10 then substring(convert(varchar(20),Budget_Cost),1,1) + ',' +
substring(convert(varchar(20),Budget_Cost),2,3) + ',' + substring(convert
(varchar(10),Budget_Cost),5,len(convert(varchar(10),Budget_Cost)))
else convert(varchar(20),Budget_Cost) end
from Sysset
--- posted by geoForum on http://delphi.newswhat.com
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|