LeadingZeros ( value, numDigits )
Converts any number into a string and pads the number with leading zeros until the number of required digits is achieved.
Be the first to rate this function Log in to vote
Kyle Williams - Show more from this author
Augusto Digital https://www.youtube.com/channel/UCpJlB7cmVNMjbjgY96MEsng |
LeadingZeros( 355, 8 )
00000355
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
Converts any number into a string and pads the number with leading zeros until the number of required digits is achieved.
Comments
Dan Shockley May 28, 2025 |
||
You could replace the hard-coded string of zeroes with this: Right ( GetAsText ( 10^numDigits ) ; numDigits ) I think that's a trick I first saw in the custom function CustomList by Agnes Barouh. |
||
Dan Shockley May 28, 2025 |
||
Update: I should have said to use this, to avoid getting scientific notation for large numbers: Right ( NumToJText ( 10^numDigits ; "" ; "" ) ; numDigits ) |
||
Kyle Williams, Augusto Digital May 28, 2025 |
||
@Dan, both of your formulas are missing the values.. Using Right ( NumToJText ( 10^numDigits & value; "" ; "" ) ; numDigits ) I was able to get this to work with up to 8 leading zeros but after that it just returns "?".. This issue is probably due to the scientific notation issues. |
||
Kyle Williams, Augusto Digital May 28, 2025 |
||
Update... This could work to replace all of the zeros, however, it does start with a leading one but would work great for most cases: NumToJText ( 10^100 ; "" ; "" ) |
||
Kyle Williams, Augusto Digital May 28, 2025 |
||
Here is the formula with Dan Shockley's suggested update: GetAsText( Right( NumToJText ( 10^100 ; "" ; "" ) & GetAsText(value); Max( numDigits; Length(value)) )) |
||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.