Print Page | Close Window

zero fill

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=21975
Printed Date: 19 May 2024 at 1:28am


Topic: zero fill
Posted By: TorLang
Subject: zero fill
Date Posted: 24 May 2016 at 1:45am
Has anyone figured out how to zero fill field using a custom formula where the field has to be a certain length, zero filled to that length, if the field value is shorter?

I would think the custom field would look different depending on if its a numeric or a text field.

for example:

field value : 345 (numeric)
fixed length: 7
right justified

will have to look like this:

0000345

field value: 34523

will have to look like this:

0034523






Replies:
Posted By: Valert16
Date Posted: 26 May 2016 at 12:48am
For example:
ToText(345, "0000000") returns "0000345"
ToText(34523, "0000000") returns "0034523"

Take a look at CR help, paragraph "Format Strings"


Posted By: lockwelle
Date Posted: 02 Jun 2016 at 8:07am
replace(right(space(x) + totext({field}, x), x)," ", "0")

as another idea...



Print Page | Close Window