web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Removing leading zeros

(0) ShareShare
ReportReport
Posted on by 779

Hi, I'm exporting a group of a decimal fields to txt and I'm getting those fields with leading zeros: 000000246 and the result I pretend is 246.
I did this funtion below and tried the same function with the parameters on DELCHAR and it didnt work.
Any tip?

DecimalNumeralZeroFormat(Amount,9)

//Respective Function

LOCAL DecimalNumeralZeroFormat(DecimalNumeral : Decimal;Length : Integer) : Text[250]
EXIT(TextZeroFormat(DELCHR(FORMAT(ROUND(ABS(DecimalNumeral),1,'<'),0,1)),Length));


*This post is locked for comments

I have the same question (0)
  • Mohana Yadav Profile Picture
    60,961 Super User 2025 Season 2 on at
    RE: Removing leading zeros

    What code do you have in TextZeroFormat function?

  • Martinho Costa Profile Picture
    779 on at
    RE: Removing leading zeros
    LOCAL TextZeroFormat(Text : Text[250];Length : Integer) : Text[250]
    IF STRLEN(Text) > Length THEN
      ERROR(Text003,Text,Length);
    EXIT(PADSTR('',Length - STRLEN(Text),'0') + Text);

  • Natalie Karolak - the BC Docs Librarian Profile Picture
    1,955 on at
    RE: Removing leading zeros

    I am unsure whether I got the point ...

    What is your desired output, and what are you getting instead?

  • Verified answer
    Mohana Yadav Profile Picture
    60,961 Super User 2025 Season 2 on at
    RE: Removing leading zeros

    TextZeroFormat function is adding the leading zeros.

    Please try to change your code by removing above function

  • Natalie Karolak - the BC Docs Librarian Profile Picture
    1,955 on at
    RE: Removing leading zeros

    Then replace the function call with FORMAT(Amount);

  • Suggested answer
    keoma Profile Picture
    32,729 on at
    RE: Removing leading zeros

    hi,

    follow msdn.microsoft.com/.../dd354973.aspx for delchr function 

    and http://msdn.microsoft.com/en-us/library/dd301101.aspx for padstr function.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
Saurav.Dhyani Profile Picture

Saurav.Dhyani 2 Super User 2025 Season 2

#2
RK-25090803-0 Profile Picture

RK-25090803-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans