Hi All,
I have a source file col that has decimal data in form 020, but when I convert it into varchar format using DecimalToString(colname), then it is automatically converted to something like 20. I would like output in form 020 (varchar data).
Can anyone pls help.
Thanks in anticipation.
Rishabh
DecimalToSting()
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 33
- Joined: Mon Nov 12, 2007 1:02 am
- Location: Bangalore
DecimalToSting()
Rishabh Sagar V
Bangalore
Bangalore
Did you try using 'Fix_xero" with the DecimalToString function?
If not please check this.
Else you can do the formatting stuff:
Please let us know your results
If not please check this.
Else you can do the formatting stuff:
Code: Select all
Right( Str('0',n) : DecimalToString(InCol,"fix_zero"), n)
Thanks and Regards!!
dspxlearn
dspxlearn
Re: DecimalToSting()
Decimal data is not stored with leading zeroes; that is a function of how you display it. The string formatting function thatvrishabhsagar wrote:...I have a source file col that has decimal data in form 020...
dspxlearn suggested should work for you when reconverting the number back to a string.
-
- Participant
- Posts: 33
- Joined: Mon Nov 12, 2007 1:02 am
- Location: Bangalore
Have used this
Hi All,
Thanks for responding... Right now I have used this to fix the problem,
Str("0",3-len(trim(DecimalToString(DSLink3.FLQ66B080_TOACDE1,"suppress_zero")))):DecimalToString(DSLink3.FLQ66B080_TOACDE1,"suppress_zero")
Since I am running out of time, I am unable to test ur solution. But when I test it, if I find any thing of interest I shall definetly bump this thread or PM.
Thanks Again.
Thanks for responding... Right now I have used this to fix the problem,
Str("0",3-len(trim(DecimalToString(DSLink3.FLQ66B080_TOACDE1,"suppress_zero")))):DecimalToString(DSLink3.FLQ66B080_TOACDE1,"suppress_zero")
Since I am running out of time, I am unable to test ur solution. But when I test it, if I find any thing of interest I shall definetly bump this thread or PM.
Thanks Again.
Rishabh Sagar V
Bangalore
Bangalore
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
The answer is NO.
A Decimal number is a binary data type. Whether it has leading zeroes or not it is stored the same way. DecimalToString() generates the shortest possible valid string.
If you want to add leading zeroes, then you must do so explicitly. For example:
A Decimal number is a binary data type. Whether it has leading zeroes or not it is stored the same way. DecimalToString() generates the shortest possible valid string.
If you want to add leading zeroes, then you must do so explicitly. For example:
Code: Select all
Right("000" : DecimalToString(InLink.TheDecimal), 3)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.