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

Keeping Leading Zeros with %Char

Status
Not open for further replies.

jsplice

Programmer
Jun 3, 2003
88
US
Hello everyone. I'm trying to do something farily simple. I have a line of code:

Code:
FullPeriod = %char(FromYear2) + PeriodToChar(i);

FullPeriod is 3A and PeriodToChar returns a 1 digit period number. When FromYear2 is '06' (representing the year 2006), FullPeriod is concatenated as '61 ' instead of with the leading zero like '061', '062', etc. How can I do this so that during the conversion, the leading zero is kept?
 
Instead of using %char, use %editcde, with the approprate edit code.

So, try this...

FullPeriod = %editc(FromYear: 'X') + PeriodToChar(i)

I think that X is the proper edit code to keep the zeros, but do not have the chart in front of me.

Good luck
 
bwtc:

'X' is indeed the correct edit code to keep leading zeros.

My rule of thumb is: use %char when formatting for a report or something (such as a display field) where you want an "edited" look to it; but use %editc when formatting for a file field.



Feles mala! Cur cista non uteris? Stramentum novum in ea posui!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top