BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to Format a String

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Peet Koekemoer
Guest





PostPosted: Tue Jun 07, 2005 11:40 am    Post subject: How to Format a String Reply with 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
Mike Shkolnik
Guest





PostPosted: Tue Jun 07, 2005 1:11 pm    Post subject: Re: How to Format a String Reply with quote



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





PostPosted: Tue Jun 07, 2005 2:32 pm    Post subject: Re: How to Format a String Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.