Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

converting a database decimal field to a number and then to string

Status
Not open for further replies.

addygoyal

Programmer
Apr 24, 2003
21
ZA
here is an example about what i want to know
decimal database feild {feild}//the value of feild = 345.00
formula: String variable stringVar S := "SomeString";
S := S +'--'+{feild}

when i use the formula in the report i want the result to be displayed as : SomeString--345
 
No need to complicate your life with variables here.

The formula you need is:

+"SomeString--"+totext({YourNumberField},0)

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
dgilsdorf@trianglepartners.com
 
+"SomeString--"+totext({YourNumberField},0)
this is working fine up to the point in removing decimal and zeros after decimal
the result is now SomeString--3,45 ie I want to remove this comma also
 
Try "SomeString--" & {YourNumberField}
The advantage of using [&] rather then [+] is that it allows you to mix numerics and text without converting everything. ToText can then be used just to modify the output.

If this fails, try
SomeString--" & totext({YourNumberField}, "###")

You don't need the zero unless the field has decimals you want to suppress, totext({YourNumberField}) should also work. But there must be something in your set-up that inserts the comma.

Defaults can be adjusted using the [File] menu, select [Options] and then Fields. But this affects everything you later do, and may affect existing fields.

All of the above applies for Crystal 8.5, which is the only version I've used.

Madawc Williams
East Anglia
Great Britain
 
I am not sure why you would get a comma on a number of 345. If however you want to remove the thousands separator, here is the formula:

+"SomeString--"+totext({YourNumberField},0,"")

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
dgilsdorf@trianglepartners.com
 
or if this is a european post and the comma is the decimal point and you want that to go

+"SomeString--"+totext({YourNumberField},0,"","")

Jim Broadbent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top