leading zeros for decimals

ReSpongebobReSpongebob Member Posts: 17
Hi,

I need convert a decimal to text, with leading zeros and a precision of 3 decimals without the decimal separator.

Examples:
4,3446 must be converted to 00004345
4,39 must be converted to 00004390

Is this possible? :-k

Comments

  • Timo_LässerTimo_Lässer Member Posts: 481
    MyDecimalText := PADSTR('',STRLEN(FORMAT(MyDecimal),'0') + FORMAT(MyDecimal);
    
    You can change the FORMAT(MyDecimal) to any formatted output you want, but you must do it twice:
    One time for the text you want to have and one time for getting the string length of this text.
    You also can put the formatted value in a text var and substitute the FORMAT(MyDecimal) in the above written code by your text var.
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • ReSpongebobReSpongebob Member Posts: 17
    Thanks a lot, Timo!

    I was able to build a solution with your help! \:D/
Sign In or Register to comment.