Focal Point
[SOLVED] Leading and trailing zeros

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/550100962

October 16, 2009, 10:10 AM
CathyB
[SOLVED] Leading and trailing zeros
Hi,

I know that there is a lot of info out there on this subject but I can't quite find exactly what I'm looking for.

I have a A15 field (000000005930000), I need it to look like 59.30. I can trim the leading zeros, but if I trim trailing then I get 593. I need to keep one trailing zero.

Any suggestions? Thanks.

This message has been edited. Last edited by: Kerry,


WEBFOCUS 7.14
WEBFOCUS.8.04
October 16, 2009, 10:15 AM
GinnyJakes
Once you've trimmed the leading zeroes, couldn't you use EDIT to pick up what now are the first 4 characters and insert the dot?
TRIM4/A5=EDIT(TRIMMED,'99.99');



Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
October 16, 2009, 10:47 AM
<JG>
I think what CathyB means she gets 59.3 but wants 059.3

If that is the case then its '0' || the trimed field
October 16, 2009, 10:48 AM
CathyB
Thank you thats really close, but I failed to mention that this field varies, one is the exsample I gave and then I could have (000000012530000) which should translate to 125.30. I could have others that (0000000112530000) which would be 1125.30. Basically this a A15 field that needs to be a D12.2 field trimming the leading zeros and all but one zero on the end.


WEBFOCUS 7.14
WEBFOCUS.8.04
October 16, 2009, 10:54 AM
mrguru
If the format of the alpha field is always the same then just convert field to numeric and divide by 100000.

 
DEFINE FILE CAR
NMX/A15 = '000000005930000';
NM/D15.2 = EDIT(NMX)/100000.00;
END
TABLE FILE CAR
PRINT CAR 
NM
IF RECORDLIMIT EQ 1
END



WF 8.2.01M
8.2.01M Reporting Server
Windows 2012 Srvr R2
PDF,Excel, HTML
Graphs - a lot of graphs
October 16, 2009, 10:59 AM
CathyB
Wow, that was like hitting the "easy" button. Thank you!


WEBFOCUS 7.14
WEBFOCUS.8.04