Type conversions

EFX never converts a value from one data type to another by itself. You always write a conversion yourself, with a conversion function (see Type conversion).

Conversion functions

From To Function Result

number

text

text

the number in standard decimal form

indicator

text

text

true or false

date

text

text

the date as year-month-day with its time zone

time

text

text

the time as hours:minutes:seconds with its time zone

duration

text

text

the duration in ISO 8601 form, for example P14D for P2W

text

number

number

the number written in the text, or NaN ("not a number") when the text is not a number

indicator

number

number

1 for TRUE, 0 for FALSE

number

indicator

indicator

FALSE for 0, TRUE for any other number

text

date

date

the date written in the text

text

time

time

the time written in the text

text

duration (days, hours, minutes, seconds)

day-time-duration

for example from 'P3D'

text

duration (months, years)

year-month-duration

for example from 'P2Y'

There is no conversion from text to indicator, from date to number or from number to date.

Operators and functions whose result has another type

The following operators and functions are not conversions, but the type of their result differs from the type of their operands.

From To Operator or function

date and date

duration

<date> - <date> (see Date and duration arithmetic)

date and duration

date

<date> + <duration>, <duration> + <date>, <date> - <duration>, add-duration, subtract-duration

number and duration

duration

<number> * <duration>, <duration> * <number>

text

number

string-length, index-of-substring

date

number

year, month, day

time

number

hours, minutes, seconds

duration

number

years, months, days

sequence, or node

number

count, count-duplicates, sum, min, max, average

sequence of texts

text

string-join

text

sequence of texts

split

number

text (templates only)

format-number

date or time

text (templates only)

format-short, format-medium, format-long

text-multilingual field

text (templates only)

the property :preferredLanguageText, the function preferred-language-text

any field

text

the property :rawValue, which gives the value as written in the notice

Correspondences without a function

  • Each type of field defined in the SDK matches an EFX data type, and a field reference gives values of that type (see Field types and their EFX data types).

  • A text-multilingual field gives texts, one for each language.

  • EFX accepts any single value where a sequence is expected: it stands for a sequence of one value. The other way round is not true: EFX never accepts a sequence where a single value is required.

  • A context variable that holds a field stands for the value of that field when you use it as a value.