TEXT
Returns the value as a text
Usage
Parameters
value |
(Required) The value to turn into text |
format |
If value is a date or a number, this is the display format to use. See “More information” below. |
Examples
More information
If given a text, it is returned as is.
Formatting a date
If value
is a date, then a format may be speficied by giving it a second value. This format is a text that contains patterns
to describe how to write the date. For example, "(yyyy)--mm//dd"
would write a date as (2024)--02//23
.
The following table lists the possible patterns and their final results:
pattern | result |
yy | Year number, last 2 digits only (00..99) |
yyyy | Full year number |
m | Month number without leading zero (1..12) |
mm | Month number with leading zero (01..12) |
mmm | Month name* abbreviated |
mmmm | Month name* |
d | Day of the month without leading zero (1..31) |
dd | Day of the month with leading zero (01..31) |
ddd | Day of the week name* abbreviated |
dddd | Day of the week name* |
Important: For the patterns resulting in a name (marked with a *
), DocuMold needs to know the language of the document.
See the @LANGUAGE
action documentation for more details.
To make a format, simply put the patterns along with other characters to match what you want to receive.
Here are examples assuming @LANGUAGE
` is set to English.
format | example |
"yyyy-mm-dd" |
2024-02-07 |
"mm-dd-yyyy" |
02-07-2024 |
"mmmm d, yyyy" |
February 7, 2024 |
"dddd, mmmm d, yyyy" |
Wednesday, February 7, 2024 |
"dd-mm-yyyy" |
07-02-2024 |
"d mmmm yyyy" |
7 February 2024 |
Any character other than “y”, “m” and “d” can be used as is. If you want to write a “y”, “m” and “d” in
your format and have it displayed as the letter itself, prefix each such letter with a backslash (\
), ex: “wh\y”.
Formatting a number
If value
is a number, then a format may be speficied by giving it a second value. This format is a text that contains
instructions to describe how to write the number. For example, "### ###!.##"
would write the 12345.6789
number this way: 12 345.68
.
Available instructions in a number’s format:
#
writes a significant digit or is removed if no such digit is available0
writes a significant digit or a 0 if no such digit is available?
writes a significant digit or a space if no such digit is available (useful for alignment when using mono-space font)!
marks the location of the decimal marker, write the marker you want to use after it. Ex:!.
to use a dot. The exclamation mark won’t be in the result.;
seperates the format into up to three sections for different cases. The value of the number will determine which section is used:- positive number: first section
- negative number: second section (if missing, the first section will be used with a minus sign (
-
) as prefix) - zero: third section (if missing, the first section will be used)
The exclamation mark (!
) is needed because different languages/countries/contexts use different symbols to separate decimals
(usually a dot or a comma) and separate groups of numbers (sometimes spaces, dots, others). To avoid mistakes, if there
is no exclamation mark (!
) in the format, there will be an error. If you don’t need decimals in your number, place the
exclamation mark (!
) at the end of the format: "### ###!"
.
Any other character between the #
, 0
, ?
and !
of the pattern is treated as a group separator. These separators are only kept if
they are between the exclamation mark (!
) and a digit instruction that wasn’t removed.
Characters not between any instructions are kept as-is.
So TEXT(1234, "$ ##'##_##!")
results in $ 12_34
.
What is meant by a significant digit:
- “10” and “000010” are the same number. The extra zeroes (on the left) are not needed, they are not significant.
- “5.0200” and “5.02” are the same number. Those zeroes (on the right) are not needed, they are not significant.
Digit instructions in the format, such as the hash (#
), are replaced by a digit from the number. The order this happens is centered on
the exclamation mark (!
), the placeholders closer to it are replaced first. So in "###!.###"
, if you have 12.34
, then DocuMold’s
step by step is:
###!.###
##2!.3##
#12!.34#
12!.34
If there aren’t enough instructions for digits to the left of the format (whole part too large), then the format will be extended by duplicating the last group of
instructions. So 11223344556
with format "### ###!.#"
gives 11 223 344 556
.
If there aren’t enough instruction for digits to the right of the format (too many decimals), then the number will be rounded to the available amount of digits using the
common rule (see function ROUND
).
If you want to write one of the instruction character in your format and have it displayed directly (instead of being transformed),
prefix each such character with a backslash (\
), ex: “# #” would give “# 123”.