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

Leading Zeros

Status
Not open for further replies.

Liz080869

Technical User
Jun 18, 2012
2
US
I have a field in Crystal Reports that should be 5 digits long but if the first numbers are zero, it drops them. How do I add leading zeros to display as 00614 instead of 614?
 
totext({field},"0000#")

_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 
But my field is not necessarily only 3 characters all the time sometimes it is 5 (which would not require the zeros) but sometimes it is 4, 2 and 1. How would I apply it for each different scenario?
 
it will work


_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 
not sure where i picked up the habit of throwing a # in. Im pretty sure totext({field},"00000") works as well

explanation from help file:
Represents numerical digits or zeros (0).
When the original number is converted, 0 characters are ignored unless the number of 0 characters in the format string extends beyond the number of significant digits in the original value. Then, for every additional 0 that appears, a zero is added to the string.

_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top