Skip to main content

Formatting values

The Format String property sets how a template control shows the value bound to it: the number of decimals, the thousands separator, the date layout and the text around the value. A second way is the alameen functions, which follow the program options. This page describes both ways and when to use each.

Set a format string​

  1. Select the control bound to a field, such as a text that shows [Price].
  2. In the Properties panel, open the Format String property, and then click its button to open the Format String Editor window.
  3. Choose the format or type it, and then close the window.
Item in Format String EditorWhat it does
CategoryGroups the formats, such as numbers and dates. Choose the category to see its formats.
Standard FormatsA list of ready-made formats for the chosen category.
Custom FormatsWhere you type the format string yourself.
Sample:Shows how a sample value looks with the chosen format before you save it.

If you choose the general format, the window shows "General format has no specific number format", which means it adds no number format.

Format string syntax​

A format string is written between braces. Inside them 0 is the value, followed by a colon and the format code. Text outside the braces prints as it is. The type of the value matters: a number format does not suit a text value.

FormatWhat it doesValueResult
{0:N2}A number with a thousands separator and two decimals.1250.51,250.50
{0:F2}A number with two decimals and no thousands separator.1250.51250.50
{0:N0}A whole number with a thousands separator.1250.51,251
{0:P1}A percentage with one decimal.0.25525.5%
{0:dd-MM-yyyy}A date with day, month and year.5 December 202605-12-2026
{0:HH:mm}A time with hours and minutes.2:30 in the afternoon14:30
Total: {0:N2}Fixed text before the value.1250.5Total: 1,250.50

alameen functions instead of a format string​

The functions ToPrice, ToQuantity, ToExchangeRate, ToDate, ToDateTime and ToTime return the value formatted by the program options: the decimals for prices, quantities and exchange rates, the thousands separator and the date layout. They are described in alameen functions. Only an administrator changes the number options behind ToPrice, ToQuantity and ToBalance, and the change applies to every user of the company file.

You wantUse
The template to follow the options of the company, so the decimals change when the company changes themThe function, such as ToPrice([Price]) in the expression of the control.
A fixed format that does not change with the optionsFormat String.
The value to be added, compared or sortedFormat String, and keep the value a number.
warning

These functions return text, not a number. Do not use them in an expression that adds, compares or tests a numeric value. The number functions accept a numeric field, and the date functions accept a date field only.

Example: an invoice line​

A line of a sales invoice has a price of 1250.5, a quantity of 10 and an invoice date of 5 December 2026.

  1. For the price, set Format String to {0:N2}. The preview prints 1,250.50.
  2. For the quantity, write the expression ToQuantity([Quantity]). The preview prints the quantity with the number of decimals set in the numbers options of the program.
  3. For the date, write the expression ToDate([Date]). The preview prints 05-12-2026 while the date layout in the options is the default one.

This page applies to alameen ERP 10, version 10.1.79.764.