# Dynamics NAV C/AL FORMAT Function and Format String Reference

> Source: https://netray.co/tools/dynamics-nav-c-al-format-string-reference
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Exact FORMAT expressions with their output for dates, decimals, times, booleans and options in NAV 2013 to 2018, plus the related text functions.

## Category

microsoft-dynamics

## Erp

Microsoft Dynamics NAV

## Audience

- NAV developer
- Business Central developer
- ERP administrator

## Tool

**Kind:** worksheet

**Mode:** reference

**Columns:**

#### Expression

**Key:** expression

**Type:** text

#### Data type

**Key:** dataType

**Type:** text

#### Output (US regional settings)

**Key:** output

**Type:** text

#### Notes

**Key:** notes

**Type:** text

**Rows:**

**Expression:** FORMAT(D)

**Data Type:** Date

**Output:** 11/05/26

**Notes:** D = 110526D (November 5, 2026). Standard format 0, follows regional settings

**Expression:** FORMAT(D,0,2)

**Data Type:** Date

**Output:** 110526D

**Notes:** C/AL code constant format: <Month,2><Day,2><Year><Closing>D

**Expression:** FORMAT(D,0,3)

**Data Type:** Date

**Output:** 26/11/05

**Notes:** <Closing><Year>/<Month,2>/<Day,2>

**Expression:** FORMAT(D,0,4)

**Data Type:** Date

**Output:** November 5, 2026

**Notes:** <Month Text> <Closing><Day>, <Year4>

**Expression:** FORMAT(D,0,5)

**Data Type:** Date

**Output:** 110526

**Notes:** <Closing><Month,2><Day,2><Year>

**Expression:** FORMAT(D,0,6)

**Data Type:** Date

**Output:** 261105

**Notes:** <Closing><Year><Month,2><Day,2>

**Expression:** FORMAT(D,0,7)

**Data Type:** Date

**Output:** 5. Nov 2026

**Notes:** <Day,2><Filler Character, >. <Month Text,3> <Year4>

**Expression:** FORMAT(D,0,9)

**Data Type:** Date

**Output:** 2026-11-05

**Notes:** XML format, independent of regional settings. Use for files and APIs

**Expression:** FORMAT(D,0,'<Day,2>/<Month,2>/<Year4>')

**Data Type:** Date

**Output:** 05/11/2026

**Notes:** Fixed European layout regardless of user locale

**Expression:** FORMAT(D,0,'<Year4><Month,2><Day,2>')

**Data Type:** Date

**Output:** 20261105

**Notes:** Common for file names and bank files

**Expression:** FORMAT(D,0,'<Month Text>')

**Data Type:** Date

**Output:** November

**Notes:** Language of the session

**Expression:** FORMAT(D,0,'<Month Text,3>')

**Data Type:** Date

**Output:** Nov

**Notes:** Length 3 truncates the month name

**Expression:** FORMAT(D,0,'<Year>')

**Data Type:** Date

**Output:** 26

**Notes:** Two-digit year; use <Year4> for 2026

**Expression:** FORMAT(D,0,'<Weekday Text>')

**Data Type:** Date

**Output:** Thursday

**Notes:** <Weekday> returns the number (1 = Monday)

**Expression:** FORMAT(D,0,'<Week>')

**Data Type:** Date

**Output:** 45

**Notes:** Week number as DATE2DWY(D,2) returns it

**Expression:** FORMAT(D,0,'<Weekday Text>, <Month Text> <Day>')

**Data Type:** Date

**Output:** Thursday, November 5

**Notes:** Mixing literal text and fields

**Expression:** FORMAT(CLOSINGDATE(D))

**Data Type:** Date

**Output:** C11/05/26

**Notes:** <Closing> prints C for a closing date

**Expression:** FORMAT(Amt)

**Data Type:** Decimal

**Output:** 1,234.5

**Notes:** Amt = 1234.5. Format 0 uses thousands separator; decimals as needed

**Expression:** FORMAT(Amt,0,1)

**Data Type:** Decimal

**Output:** 1234.5

**Notes:** <Sign><Integer><Decimals>, no thousands separator

**Expression:** FORMAT(Amt,0,2)

**Data Type:** Decimal

**Output:** 1234.5

**Notes:** <Sign><Integer><Decimals><Comma,.>: code constant format, decimal point always a period

**Expression:** FORMAT(-Amt,0,3)

**Data Type:** Decimal

**Output:** 1,234.5-

**Notes:** <Integer Thousand><Decimals><Sign,1>, trailing sign

**Expression:** FORMAT(Amt,0,9)

**Data Type:** Decimal

**Output:** 1234.5

**Notes:** XML format: period decimal, no separators, regional-independent

**Expression:** FORMAT(Amt,0,'<Precision,2:2><Standard Format,0>')

**Data Type:** Decimal

**Output:** 1,234.50

**Notes:** Force exactly 2 decimals on standard format 0

**Expression:** FORMAT(Amt,0,'<Precision,2:2><Integer><Decimals>')

**Data Type:** Decimal

**Output:** 1234.50

**Notes:** 2 decimals, no thousands separator

**Expression:** FORMAT(-Amt,0,'<Sign><Integer><Decimals>')

**Data Type:** Decimal

**Output:** -1234.5

**Notes:** Leading minus sign

**Expression:** FORMAT(Qty,0,'<Integer,10><Filler Character,0>')

**Data Type:** Decimal

**Output:** 0000001234

**Notes:** Qty = 1234. Zero-padded fixed width for flat files

**Expression:** FORMAT(T)

**Data Type:** Time

**Output:** 2:30:05 PM

**Notes:** T = 143005T. Standard format 0, US settings

**Expression:** FORMAT(T,0,'<Hours24,2>:<Minutes,2>:<Seconds,2>')

**Data Type:** Time

**Output:** 14:30:05

**Notes:** 24-hour clock regardless of locale

**Expression:** FORMAT(T,0,'<Hours24,2><Filler Character,0><Minutes,2>')

**Data Type:** Time

**Output:** 1430

**Notes:** Compact HHMM

**Expression:** FORMAT(CREATEDATETIME(D,T),0,9)

**Data Type:** DateTime

**Output:** 2026-11-05T19:30:05Z

**Notes:** XML format is UTC. Example assumes a UTC-5 service tier time zone

**Expression:** FORMAT(TRUE)

**Data Type:** Boolean

**Output:** Yes

**Notes:** Caption text in the session language

**Expression:** FORMAT(TRUE,0,2)

**Data Type:** Boolean

**Output:** 1

**Notes:** <Number>: 1 or 0

**Expression:** FORMAT(TRUE,0,9)

**Data Type:** Boolean

**Output:** true

**Notes:** XML format

**Expression:** FORMAT(SalesHeader."Document Type")

**Data Type:** Option

**Output:** Order

**Notes:** Option caption in the session language

**Expression:** FORMAT(SalesHeader."Document Type",0,2)

**Data Type:** Option

**Output:** 1

**Notes:** Option ordinal; Order is 1 in table 36

**Expression:** EVALUATE(D,'2026-11-05',9)

**Data Type:** Date

**Output:** D = 11/05/26, returns TRUE

**Notes:** Read back an XML-format value written with FORMAT(..,0,9)

**Expression:** STRPOS('ABC-123','-')

**Data Type:** Text

**Output:** 4

**Notes:** 1-based; 0 if not found

**Expression:** COPYSTR('ABC-123',5)

**Data Type:** Text

**Output:** 123

**Notes:** From position 5 to the end; COPYSTR('ABC-123',1,3) = ABC

**Expression:** PADSTR('AB',5,'*')

**Data Type:** Text

**Output:** AB***

**Notes:** Pads or truncates to the length

**Expression:** DELCHR(' A B ','=',' ')

**Data Type:** Text

**Output:** AB

**Notes:** '<' leading, '>' trailing, '=' all occurrences

**Expression:** CONVERTSTR('A-B-C','-','/')

**Data Type:** Text

**Output:** A/B/C

**Notes:** Character-by-character replacement, both strings same length

**Expression:** INCSTR('INV-0099')

**Data Type:** Code

**Output:** INV-0100

**Notes:** Increments the rightmost number; returns empty text if there is none

**Expression:** STRSUBSTNO('Order %1 for %2','SO-1001','10000')

**Data Type:** Text

**Output:** Order SO-1001 for 10000

**Notes:** %1 to %10 placeholders, values formatted with FORMAT

**Notes:** 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.

## Content

**Intro:** 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.

**Sections:**

#### How to use it

**Body:** 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

**Body:** 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.

**Bullets:**

- 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

**Body:** 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

**Body:** 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.

**Cta:** 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.

**Faq:**

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

**Answer:** 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?

**Answer:** 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?

**Answer:** 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?

**Answer:** 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.

## Search terms

dynamics nav format date, dynamics nav format decimal, dynamics nav format, dynamics nav strpos, c/al format function, nav format string standard format, nav format 9 xml

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
