shingonati0n
shingonati0n

Reputation: 157

Format number formula

I have a number field in Crystal Report that must be shown in a specific format:

Eg:

12345678

must be shown as

1234-5678

I'm using a formula to transform the number to string, substring it 2 times and concatenate both values:

StringVar ordenT := Totext(GroupName ({DataTableInfCR.Orden}));
StringVar OrdenT1 := MID(ordenT,1,4);
StringVar OrdenT2 := MID(ordenT,4,4);
StringVar NroOrden := OrdenT1 +"-"+ OrdenT2;

However, the output for this code ends up being somthing like this:

12.3-45.6

I'm sure it because the default number format is with dots (ex: 12345678 will be 12.345.678)

How can I change the format via formula before my code??

Thanks!

Upvotes: 0

Views: 13681

Answers (1)

campagnolo_1
campagnolo_1

Reputation: 2750

To answer your question, to remove the decimals you use

StringVar ordenT := Totext(GroupName ({DataTableInfCR.Orden}),0);

or

StringVar ordenT := cStr(GroupName ({DataTableInfCR.Orden}),0);

EDIT:

See if this will take care of it all:

totext(GroupName({DataTableInfCR.Orden}),0,""),"xxxx-xxxx")

Upvotes: 1

Related Questions