{"title":"System.Format(Any, Integer, Text) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/system/system-format-joker-integer-string-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/system/system-format-joker-integer-string-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/system/system-format-joker-integer-string-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Formats a value into a string.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"System.Format(Any, Integer, Text) Method","slug":"systemformatany-integer-text-method","at":0,"chars":3002},{"level":2,"title":"Syntax","slug":"syntax","at":134,"chars":170},{"level":2,"title":"Parameters","slug":"parameters","at":304,"chars":572},{"level":2,"title":"Return Value","slug":"return-value","at":876,"chars":52},{"level":2,"title":"Remarks","slug":"remarks","at":928,"chars":754},{"level":2,"title":"Example 1","slug":"example-1","at":1682,"chars":869},{"level":2,"title":"Example 2","slug":"example-2","at":2551,"chars":252},{"level":2,"title":"Related information","slug":"related-information","at":2803,"chars":199}],"text":"# System.Format(Any, Integer, Text) Method\n> Version: _Available or changed with runtime version 1.0._\nFormats a value into a string.\n## Syntax\n```al\nString :=   System.Format(Value: Any, Length: Integer, FormatString: Text)\n```\n> NOTE\n> This method can be invoked without specifying the data type name.\n## Parameters\nValue\nType: ../any/any-data-type\nThis is an AL variable (expression) of any simple data type, such as Option, Integer, BigInteger, Decimal, Char, Text, Code, Date, Time, DateTime, Boolean, or GUID. If, when the system formats Value, the result is a value larger than the maximum length MAXSTRLEN method (Code, Text) of String, a run-time error occurs.\nLength\nType: ../integer/integer-data-type\nThis optional parameter specifies the length of String.\nFormatString\nType: ../text/text-data-type\nA literal string that defines a format as in the Format Property.\n## Return Value\nString\nType: ../text/text-data-type\n## Remarks\nFor the Length parameter, the following rules apply:\n If Length = 0 then the entire value is returned (default).\n If Length > 0 then the returned string will be exactly Length characters.\n  If Value is less than Length characters, then either leading or trailing spaces are inserted, depending on the format that you select.\n  If Value exceeds Length characters, then String is truncated to Length characters.\n If Length < 0 then the returned string will not have leading or trailing spaces.\n  If Value is less than Length characters, the length of String will equal the length of Value.\n  If Value exceeds Length characters, then String is truncated to Length characters.\nSee Formatting Values, Dates, and Time<../../devenv-format-property>.\n## Example 1\n```al\nvar\n    Text000: Label 'The formatted value >%1<';\nbegin\n    Message(Text000, Format(-123456.78, 12, 3));\n    Message(Text000, Format(-123456.78, 12, '<Standard Format,3>'));\n    Message(Text000, Format(-123456.78, 12, '<Integer Thousand><Decimals><Sign,1>'));\nend;\n\n```\nThe Regional and Language settings on the computer on which you run the code affect how the string is displayed. For example, on a computer that has the regional format set to English (United States), the message window displays the following:\nThe formatted value: > 123,456.78-\\<\nThe formatted value: > 123,456.78-\\<\nThe formatted value: > 123,456.78-\\<\nOn a computer that has the regional format set to Danish \\(Denmark\\), the message window displays the following:\nThe formatted value: > 123.456,78-\\<\nThe formatted value: > 123.456,78-\\<\nThe formatted value: > 123.456,78-\\<\n## Example 2\nThis example shows how to use a string to build a format.\n```al\nvar\n    Text000: Label 'Today is %1';\nbegin\n    Message(Text000, Format(Today,0,'<Month Text> <Day>'));\nend;\n```\nThe message window displays the following:\nToday is April 15.\n## Related information\nFormatting Values, Dates, and Time<../../devenv-format-property>\nsystem-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}