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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TRUNCATE? 1

Status
Not open for further replies.

Jlok

IS-IT--Management
Mar 28, 2002
23
US
Trying to use truncate to return a whole number...

TRUNCATE ({field})

What am I doing wrong? Table contains order values. All entries have a 2 place decimal 123.45 I want to return 123??

What am I missing?

Thanks-
 
If you are getting 123.00, you just need to format the number display to remove the zeros. You can use the decrease decimal icon in the toolbar.

-LB
 
I tried INT({table.field}) it returned 12300 instead of 123.50

Looking to get 123
 
Int doesn't return 12300, unless soemthing is wrong with your connectivity or some such.

LB may have nailed it, and you're just speaking of display characteristics, not a value.

With Oracle and the wrong ODBC driver, there can be precision errors, but otherwiswe Crystal shouldn't do anything like what you describe.

-k
 
This is what I got, It is a formula for a barcode

if {TEMP_ORDER_HEADER.BVSUBTOTAL} > 100 then
IDAutomationFontEncoderCode128 ({TEMP_ORDER_HEADER.NUMBER} & {TEMP_ORDER_HEADER.BVSUBTOTAL},0 )
else IDAutomationFontEncoderCode128 ({TEMP_ORDER_HEADER.NUMBER},0)


I need for {TEMP_ORDER_HEADER.BVSUBTOTAL} to return a whole number with no decimals. As it is in the DB now it has decimals.
 
Too bad you felt the type of DB type/connectivity, and the data type of {TEMP_ORDER_HEADER.BVSUBTOTAL} unimportant to post, it may prove key to the solution.

So this doesn't show that you used the INT function anywhere...

Anyway, if they are numerics, try:

if {TEMP_ORDER_HEADER.BVSUBTOTAL} > 100 then
IDAutomationFontEncoderCode128 ({TEMP_ORDER_HEADER.NUMBER} & totext({TEMP_ORDER_HEADER.BVSUBTOTAL},"",0,),0 )
else IDAutomationFontEncoderCode128 ({TEMP_ORDER_HEADER.NUMBER},0)

If it's a string type, try:

if {TEMP_ORDER_HEADER.BVSUBTOTAL} > 100 then
IDAutomationFontEncoderCode128 ({TEMP_ORDER_HEADER.NUMBER} & totext(val({TEMP_ORDER_HEADER.BVSUBTOTAL}),"",0),0 )
else IDAutomationFontEncoderCode128 ({TEMP_ORDER_HEADER.NUMBER},0)

-k
 
Thank you-

if {TEMP_ORDER_HEADER.BVSUBTOTAL} > 100 then
IDAutomationFontEncoderCode128 ({TEMP_ORDER_HEADER.NUMBER} & totext({TEMP_ORDER_HEADER.BVSUBTOTAL},0),0 )
else IDAutomationFontEncoderCode128 ({TEMP_ORDER_HEADER.NUMBER},0)

That did it!
 
You can also use a SQL Expression and cast/convert the data PRIOR to it returning from the database, improving performance, hence in future posts please include background information.

Glad it worked out.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top