Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Answered

System.Format() for leading zeroes

Posted on by 29

Hi everyone!

I'm trying to write a function that will take values from a table and write them to a plain text file.

In order to make the text easier to read, I'm trying to get the values in some of the columns to all be the same length. I want to achieve this by using leading zeroes.

So, let's say I want all the values to be five characters in length. If the value in the column was 99, it would be written as 00099. If it was 999, it would be written as 00999.

I understand the function System.Format() can help me achieve this, but unfortunately I haven't been able to figure out how. Does anyone know what value I have to give in the Format parameter in order to achieve this kind of result? Or maybe an alternate solution altogether?

Thanks for your time!

Categories:
  • Verified answer
    YUN ZHU Profile Picture
    YUN ZHU 68,664 Super User 2024 Season 2 on at
    RE: System.Format() for leading zeroes

    Hi, here are two great examples that hopefully give you some hints.

    (99+) how to format quantity - Dynamics 365 Business Central Forum Community Forum

    Thanks

    ZHU

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,339 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,177 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans