Microsoft DynamicsFree referencePDF, Excel, Word exportMicrosoft Dynamics NAVAll Microsoft Dynamics NAV and Business Central on-prem tools

Dynamics NAV C/AL FORMAT Function and Format String Reference

This reference lists exact C/AL FORMAT expressions and their output for Dynamics NAV 2013 to 2018, with the same tokens working in AL for Business Central on-premises. Search a data type or token, copy the expression and check the output against your regional settings.

Download:
ExpressionData typeOutput (US regional settings)Notes
FORMAT(D)
Date
11/05/26
D = 110526D (November 5, 2026). Standard format 0, follows regional settings
FORMAT(D,0,2)
Date
110526D
C/AL code constant format: <Month,2><Day,2><Year><Closing>D
FORMAT(D,0,3)
Date
26/11/05
<Closing><Year>/<Month,2>/<Day,2>
FORMAT(D,0,4)
Date
November 5, 2026
<Month Text> <Closing><Day>, <Year4>
FORMAT(D,0,5)
Date
110526
<Closing><Month,2><Day,2><Year>
FORMAT(D,0,6)
Date
261105
<Closing><Year><Month,2><Day,2>
FORMAT(D,0,7)
Date
5. Nov 2026
<Day,2><Filler Character, >. <Month Text,3> <Year4>
FORMAT(D,0,9)
Date
2026-11-05
XML format, independent of regional settings. Use for files and APIs
FORMAT(D,0,'<Day,2>/<Month,2>/<Year4>')
Date
05/11/2026
Fixed European layout regardless of user locale
FORMAT(D,0,'<Year4><Month,2><Day,2>')
Date
20261105
Common for file names and bank files
FORMAT(D,0,'<Month Text>')
Date
November
Language of the session
FORMAT(D,0,'<Month Text,3>')
Date
Nov
Length 3 truncates the month name
FORMAT(D,0,'<Year>')
Date
26
Two-digit year; use <Year4> for 2026
FORMAT(D,0,'<Weekday Text>')
Date
Thursday
<Weekday> returns the number (1 = Monday)
FORMAT(D,0,'<Week>')
Date
45
Week number as DATE2DWY(D,2) returns it
FORMAT(D,0,'<Weekday Text>, <Month Text> <Day>')
Date
Thursday, November 5
Mixing literal text and fields
FORMAT(CLOSINGDATE(D))
Date
C11/05/26
<Closing> prints C for a closing date
FORMAT(Amt)
Decimal
1,234.5
Amt = 1234.5. Format 0 uses thousands separator; decimals as needed
FORMAT(Amt,0,1)
Decimal
1234.5
<Sign><Integer><Decimals>, no thousands separator
FORMAT(Amt,0,2)
Decimal
1234.5
<Sign><Integer><Decimals><Comma,.>: code constant format, decimal point always a period
FORMAT(-Amt,0,3)
Decimal
1,234.5-
<Integer Thousand><Decimals><Sign,1>, trailing sign
FORMAT(Amt,0,9)
Decimal
1234.5
XML format: period decimal, no separators, regional-independent
FORMAT(Amt,0,'<Precision,2:2><Standard Format,0>')
Decimal
1,234.50
Force exactly 2 decimals on standard format 0
FORMAT(Amt,0,'<Precision,2:2><Integer><Decimals>')
Decimal
1234.50
2 decimals, no thousands separator
FORMAT(-Amt,0,'<Sign><Integer><Decimals>')
Decimal
-1234.5
Leading minus sign
FORMAT(Qty,0,'<Integer,10><Filler Character,0>')
Decimal
0000001234
Qty = 1234. Zero-padded fixed width for flat files
FORMAT(T)
Time
2:30:05 PM
T = 143005T. Standard format 0, US settings
FORMAT(T,0,'<Hours24,2>:<Minutes,2>:<Seconds,2>')
Time
14:30:05
24-hour clock regardless of locale
FORMAT(T,0,'<Hours24,2><Filler Character,0><Minutes,2>')
Time
1430
Compact HHMM
FORMAT(CREATEDATETIME(D,T),0,9)
DateTime
2026-11-05T19:30:05Z
XML format is UTC. Example assumes a UTC-5 service tier time zone
FORMAT(TRUE)
Boolean
Yes
Caption text in the session language
FORMAT(TRUE,0,2)
Boolean
1
<Number>: 1 or 0
FORMAT(TRUE,0,9)
Boolean
true
XML format
FORMAT(SalesHeader."Document Type")
Option
Order
Option caption in the session language
FORMAT(SalesHeader."Document Type",0,2)
Option
1
Option ordinal; Order is 1 in table 36
EVALUATE(D,'2026-11-05',9)
Date
D = 11/05/26, returns TRUE
Read back an XML-format value written with FORMAT(..,0,9)
STRPOS('ABC-123','-')
Text
4
1-based; 0 if not found
COPYSTR('ABC-123',5)
Text
123
From position 5 to the end; COPYSTR('ABC-123',1,3) = ABC
PADSTR('AB',5,'*')
Text
AB***
Pads or truncates to the length
DELCHR(' A B ','=',' ')
Text
AB
'<' leading, '>' trailing, '=' all occurrences
CONVERTSTR('A-B-C','-','/')
Text
A/B/C
Character-by-character replacement, both strings same length
INCSTR('INV-0099')
Code
INV-0100
Increments the rightmost number; returns empty text if there is none
STRSUBSTNO('Order %1 for %2','SO-1001','10000')
Text
Order SO-1001 for 10000
%1 to %10 placeholders, values formatted with FORMAT

Outputs assume US regional settings and the ENU language for the session, with D = 110526D (Thursday, November 5, 2026), Amt = 1234.5, Qty = 1234 and T = 143005T. Standard formats 0 and 1 follow the user's region; use format 9 or an explicit format string for anything another program will read.

Exporting NAV data to another system?

Send us the target file layout and we will check your FORMAT strings and EVALUATE round trip for your NAV version.

Optional. The tool and every export work without this. No spam.

Was this tool useful?

How to use it

Search the table for the data type (Date, Decimal, Time) or a token such as Month Text or Precision. The Expression column is valid C/AL you can paste into a codeunit or report trigger; replace D, Amt, T and Qty with your variables. The signature is FORMAT(Value [, Length] [, FormatNumber | FormatString]). Length 0 means dynamic length. FormatNumber selects a standard format (0, 1, 2, ... 9) and FormatString builds your own from fields like <Day,2> and attributes like <Filler Character,0>.

The standard formats behind the table

Microsoft defines standard formats per data type. Format 0 is the standard display format, 1 is the edit format, 2 is the C/AL code constant format and 9 is the XML format. Dates also have formats 3 to 7 and decimals have 3 and 4 with a trailing sign. Formats 0 and 1 change with the user's regional settings, which is why a report that prints 11/05/26 for one user prints 05-11-26 for another. Format 9 returns ISO dates (2026-11-05), a period decimal separator and true/false for booleans, and DateTime values in UTC.

  • Date fields: Day, Month, Month Text, Quarter, Year, Year4, Week, Weekday, Weekday Text, Closing
  • Decimal fields: Sign, Integer, Integer Thousand, Decimals
  • Time fields: Hours24, Hours12, Minutes, Seconds, Thousands, AM/PM
  • Attributes: Standard Format, Precision, Filler Character, Comma, 1000Character, Overflow

Worked example: a bank file line

A payment export needs date YYYYMMDD, amount with two decimals and no separator, and a 10-digit zero-padded reference. In C/AL: Line := FORMAT(PostingDate,0,'<Year4><Month,2><Day,2>') + FORMAT(Amount,0,'<Precision,2:2><Integer><Decimals>') + FORMAT(RefNo,0,'<Integer,10><Filler Character,0>'). For a payment of 1234.5 on November 5, 2026 with reference 1234 this gives 20261105, 1234.50 and 0000001234 on every client, whatever the user's locale. If the bank wants the period removed, wrap the amount in DELCHR(..,'=','.').

Gotchas

FORMAT(Decimal) without a format string uses thousands separators and the user's decimal symbol, so values written to CSV break when imported elsewhere. Always use 9 or an explicit string for files, and EVALUATE(Var, Text, 9) to read them back. FORMAT of an option or boolean returns translated captions, so do not compare FORMAT output in code; compare the option value instead. DateTime format 9 converts to UTC, which surprises people expecting local time. <Year> is two digits; reports printed in 2026 with <Year> show 26.

Frequently Asked Questions

How do I format a date as dd/mm/yyyy in Dynamics NAV?

Use FORMAT(MyDate,0,'<Day,2>/<Month,2>/<Year4>'). The ,2 length on Day and Month adds the leading zero and Year4 gives the full year. Because it is an explicit format string, the output is the same for every user regardless of the Windows or NAV regional settings.

How do I format a decimal with two decimal places in NAV?

Use FORMAT(Amt,0,'<Precision,2:2><Standard Format,0>') for display with thousands separators, or FORMAT(Amt,0,'<Precision,2:2><Integer><Decimals>') without them. Precision takes minimum:maximum decimal places. ROUND(Amt,0.01) rounds the value itself but does not force trailing zeros in the text.

What does FORMAT(Value,0,9) do?

Format 9 is the XML format. Dates come out as YYYY-MM-DD, decimals use a period with no separators, booleans are true or false, options are their ordinal, and DateTime values are UTC with a Z suffix. It is the safe choice for files, web services and anything read by EVALUATE(Var, Text, 9).

How does STRPOS work in Dynamics NAV?

STRPOS(String, SubString) returns the 1-based position of the first occurrence of SubString, or 0 if it is not found. It is case-sensitive. Combine it with COPYSTR to split text, for example COPYSTR(Txt, STRPOS(Txt,'-') + 1) returns everything after the first hyphen.

If you want your NAV users to ask for documents and balances in plain English on your own servers, with dates and amounts formatted correctly, we can set that up.

ArchRay builder
Design the on-prem AI stack for Microsoft Dynamics NAV and Business Central on-prem: model, GPUs, RAG pipeline, guardrails
See memory, speed and cost as you swap parts, then export the diagram. Free, in your browser.
Open the builder

Keep exploring

Free tools

ERP fixes and how-tos

AI on your ERP

Integrations

Software