Tuesday, January 4, 2011

Crystal report Function to format with leading Zeroes..

hey folks .. 

this is something that i have come across while doing some development .
my requirement was to format integer database column with leading zeroes with Crystal Report.

i have a dataset called OrderDetails and i am formatting it to have 10 digits where the leading digits will be filled with zeroes. e.g. 21 will be 0000000021


this is how i did it.
in crystal report you have to write a function . (write click formula field then select new)

ReplicateString ("0",10-Length(cstr ({OrderDetails.Id},0,""))) +cstr({OrderDetails.Id},0,"") 
simple like this
P.S remember save,press x+2 button to validate and add this to your report lol ...!!!!

No comments:

Post a Comment