Functions from A - D

abs

Return the absolute value of the specified number.

abs(<number>)
ParameterRequiredTypeDescription
<number>YesnumberNumber to get absolute value of
Return valueTypeDescription
<result>numberThe result from computing the absolute value.

Examples

These examples compute the absolute value:

abs(3.12134)
abs(-3.12134)

And both return the result 3.12134.

add

Return the result from adding two or more numbers (pure number case) or concatenating two or more strings (other case).

add(<item1>, <item2>, ...)
ParameterRequiredTypeDescription
<item1>, <item2>,...Yesanyitems
Return valueTypeDescription
<result-sum>number or stringThe result from adding the specified numbers or the concat result.

Example

This example adds the specified numbers:

add(1, 1.5)

And returns the result 2.5.

This example concatenates the specified items:

add('hello',null)
add('hello','world')

And returns the results

  • hello
  • helloworld

addDays

Add a number of days to a timestamp in an optional locale format.

addDays('<timestamp>', <days>, '<format>'?, '<locale>'?)

ParameterRequiredTypeDescription
<timestamp>YesstringThe string that contains the timestamp which must be standard UTC ISO format YYYY-MM-DDTHH:mm:ss.fffZ.
<days>YesintegerThe positive or negative number of days to add.
<format>NostringA custom format pattern. The default format for the timestamp is UTC ISO format, YYYY-MM-DDTHH:mm:ss.fffZ, which complies with ISO 8601.
<locale>NostringAn optional locale of culture information.
Return valueTypeDescription
<updated-timestamp>stringThe timestamp plus the specified number of days

Example 1

This example adds 10 days to the specified timestamp:

addDays('2018-03-15T13:00:00.000Z', 10)

And returns the result 2018-03-25T00:00:00.000Z.

Example 2

This example subtracts five days from the specified timestamp:

addDays('2018-03-15T00:00:00.000Z', -5)

And returns the result 2018-03-10T00:00:00.000Z.

Example 3

This example adds 1 day to the specified timestamp in the de-DE locale:

addDays('2018-03-15T13:00:00.000Z', 1, '', 'de-dE')

And returns the result 16.03.18 13:00:00.

addHours

Add a number of hours to a timestamp in an optional locale format.

addHours('<timestamp>', <hours>, '<format>'?, '<locale>'?)
ParameterRequiredTypeDescription
<timestamp>YesstringThe string that contains the timestamp.
<hours>YesintegerThe positive or negative number of hours to add.
<format>NostringA custom format pattern. The default format for the timestamp is UTC ISO format, YYYY-MM-DDTHH:mm:ss.fffZ, which complies with ISO 8601.
<locale>NostringAn optional locale of culture information.
Return valueTypeDescription
<updated-timestamp>stringThe timestamp plus the specified number of hours

Example 1

This example adds 10 hours to the specified timestamp:

addHours('2018-03-15T00:00:00.000Z', 10)

And returns the result 2018-03-15T10:00:00.000Z.

Example 2

This example subtracts five hours from the specified timestamp:

addHours('2018-03-15T15:00:00.000Z', -5)

And returns the result 2018-03-15T10:00:00.000Z.

Example 3

This example adds 2 hours to the specified timestamp in the de-DE locale:

addHours('2018-03-15T13:00:00.000Z', 2, '', 'de-DE')

And returns the result 15.03.18 15:00:00.

addMinutes

Add a number of minutes to a timestamp in an optional locale format.

addMinutes('<timestamp>', <minutes>, '<format>'?, '<locale>'?)

ParameterRequiredTypeDescription
<timestamp>YesstringThe string that contains the timestamp
<minutes>YesintegerThe positive or negative number of minutes to add
<format>NostringA custom format pattern. Default: UTC ISO format YYYY-MM-DDTHH:mm:ss.fffZ
<locale>NostringAn optional locale of culture information
Return valueTypeDescription
<updated-timestamp>stringThe timestamp plus the specified number of minutes

Example 1

This example adds 10 minutes to the specified timestamp:

addMinutes('2018-03-15T00:10:00.000Z', 10)

And returns the result 2018-03-15T00:20:00.000Z.

Example 2

This example subtracts five minutes from the specified timestamp:

addMinutes('2018-03-15T00:20:00.000Z', -5)

And returns the result 2018-03-15T00:15:00.000Z.

Example 3

This example adds 30 minutes to the specified timestamp in the de-DE locale:

addMinutes('2018-03-15T00:00:00.000Z', 30, '', 'de-DE')

And returns the result 15.03.18 13:30:00.

addOrdinal

Return the ordinal number of the input number.

addOrdinal(<number>)

ParameterRequiredTypeDescription
<number>YesintegerThe numbers to convert to an ordinal number
Return valueTypeDescription
<result>stringThe ordinal number converted from the input number

Example

addOrdinal(11)
addOrdinal(12)
addOrdinal(13)
addOrdinal(21)
addOrdinal(22)
addOrdinal(23)

And respectively returns these results:

  • 11th
  • 12th
  • 13th
  • 21st
  • 22nd
  • 23rd

addProperty

Add a property and its value, or name-value pair, to a JSON object, and return the updated object. If the object already exists at runtime the function throws an error.

addProperty('<object>', '<property>', value)

ParameterRequiredTypeDescription
<object>YesobjectThe JSON object where you want to add a property
<property>YesstringThe name of the property to add
<value>YesanyThe value of the property
Return valueTypeDescription
<updated-object>objectThe updated JSON object after adding a new property

Example

This example adds the accountNumber property to the customerProfile object, which is converted to JSON with the json() function. The function assigns a value that is generated by the newGuid() function, and returns the updated object:

addProperty(json('customerProfile'), 'accountNumber', newGuid())

addSeconds

Add a number of seconds to a timestamp.

addSeconds('<timestamp>', <seconds>, '<format>'?)

ParameterRequiredTypeDescription
<timestamp>YesstringThe string that contains the timestamp
<seconds>YesintegerThe positive or negative number of seconds to add
<format>NostringA custom format pattern. Default: UTC ISO format YYYY-MM-DDTHH:mm:ss.fffZ
Return valueTypeDescription
<updated-timestamp>stringThe timestamp plus the specified number of seconds

Example 1

This example adds 10 seconds to the specified timestamp:

addSeconds('2018-03-15T00:00:00.000Z', 10)

And returns the result 2018-03-15T00:00:10.000Z.

Example 2

This example subtracts five seconds to the specified timestamp:

addSeconds('2018-03-15T00:00:30.000Z', -5)

And returns the result 2018-03-15T00:00:25.000Z.

addToTime

Add a number of time units to a timestamp in an optional locale format. See also getFutureTime().

addToTime('<timestamp>', '<interval>', <timeUnit>, '<format>'?, '<locale>'?)

ParameterRequiredTypeDescription
<timestamp>YesstringThe string that contains the timestamp
<interval>YesintegerThe number of specified time units to add
<timeUnit>YesstringThe unit of time to use with interval. Possible units are "Second", "Minute", "Hour", "Day", "Week", "Month", and "Year".
<format>NostringA custom format pattern. Default: UTC ISO format YYYY-MM-DDTHH:mm:ss.fffZ, which complies with ISO 8601.
<locale>NostringAn optional locale of culture information
Return valueTypeDescription
<updated-timestamp>stringThe timestamp plus the number of specified time units with the given format.

Example 1

This example adds one day to specified timestamp.

addToTime('2018-01-01T00:00:00.000Z', 1, 'Day')

And returns the result 2018-01-02T00:00:00.000Z.

Example 2

This example adds two weeks to the specified timestamp.

addToTime('2018-01-01T00:00:00.000Z', 2, 'Week', 'MM-DD-YY')

And returns the result in the 'MM-DD-YY' format as 01-15-18.

all

Determine whether all elements of a sequence satisfy a condition.

all(<sequence>, <item>, <condition>)

ParameterRequiredTypeDescription
<sequence>YesobjectA sequence to be evaluated.
<item>YesstringRefers to the elements to evaluate in the sequence.
<condition>YesexpressionThe expression to evaluate the condition.
Return valueTypeDescription
true or falseBooleanReturn true if all elements satisfy a condition. Return false if at least one doesn't.

Examples

These examples determine if all elements of a sequence satisfy a condition:

all(createArray(1, 'cool'), item, isInteger(item))
all(createArray(1, 2), item => isInteger(item))

And return the following results respectively:

  • false, because both items in the sequence aren't integers.
  • true, because both items in the sequence are integers.

and

Check whether all expressions are true. Return true if all expressions are true, or return false if at least one expression is false.

and(<expression1>, <expression2>, ...)

ParameterRequiredTypeDescription
<expression1>, <expression2>, ...YesBooleanThe expressions to check
Return valueTypeDescription
true or falseBooleanReturn true if all expressions are true. Return false if at least one expression is false.

Example 1

These examples check whether the specified Boolean values are all true:

and(true, true)
and(false, true)
and(false, false)

And respectively returns these results:

  • Both expressions are true, so the functions returns true.
  • One expression is false, so the functions returns false.
  • Both expressions are false, so the function returns false.

Example 2

These examples check whether the specified expressions are all true:

and(equals(1, 1), equals(2, 2))
and(equals(1, 1), equals(1, 2))
and(equals(1, 2), equals(1, 3))

And respectively returns these results:

  • Both expressions are true, so the functions returns true.
  • One expression is false, so the functions returns false.
  • Both expressions are false, so the functions returns false.

any

Determine whether any elements of a sequence satisfy a condition.

all(<sequence>, <item>, <condition>)

ParameterRequiredTypeDescription
<sequence>YesobjectA sequence to be evaluated.
<item>YesstringRefers to the elements to evaluate in the sequence.
<condition>YesexpressionThe expression to evaluate the condition.
Return valueTypeDescription
true or falseBooleanReturn true if all elements satisfy the condition. Return false if at least one doesn't.

Examples

These examples determine if all elements of a sequence satisfy a condition:

any(createArray(1, 'cool'), item, isInteger(item))
any(createArray('first', 'cool'), item => isInteger(item))

And return the following results respectively:

  • true, because at least one item in the sequence is an integer
  • false, because neither item in the sequence is an integer.

average

Return the number average of a numeric array.

average(<numericArray>)

ParameterRequiredTypeDescription
<numericArray>Yesarray of numberThe input array to calculate the average
Return valueTypeDescription
<average-of-array>numberThe average value of the given array

Example

This example calculates the average of the array in createArray():

average(createArray(1,2,3))

And returns the result 2.

base64

Return the base64-encoded version of a string or byte array.

base64('<value>')

ParameterRequiredTypeDescription
<value>Yesstring or byte arrayThe input string
Return valueTypeDescription
<base64-string>stringThe base64-encoded version of the input string

Example 1

This example converts the string hello to a base64-encoded string:

base64('hello')

And returns the result "aGVsbG8=".

Example 2

This example takes byteArr, which equals new byte[] { 3, 5, 1, 12 }:

base64('byteArr')

And returns the result "AwUBDA==".

base64ToBinary

Return the binary array of a base64-encoded string.

base64ToBinary('<value>')

ParameterRequiredTypeDescription
<value>YesstringThe base64-encoded string to convert
Return valueTypeDescription
<binary-for-base64-string>byte arrayThe binary version of the base64-encoded string

Example

This example converts the base64-encoded string AwUBDA== to a binary string:

base64ToBinary('AwUBDA==')

And returns the result new byte[] { 3, 5, 1, 12 }.

base64ToString

Return the string version of a base64-encoded string, effectively decoding the base64 string.

base64ToString('<value>')

ParameterRequiredTypeDescription
<value>YesstringThe base64-encoded string to decode
Return valueTypeDescription
<decoded-base64-string>stringThe string version of a base64-encoded string

Example

This example converts the base64-encoded string aGVsbG8= to a decoded string:

base64ToString('aGVsbG8=')

And returns the result hello.

binary

Return the binary version of a string.

binary('<value>')

ParameterRequiredTypeDescription
<value>YesstringThe string to convert
Return valueTypeDescription
<binary-for-input-value>byte arrayThe binary version of the specified string

Example

This example converts the string hello to a binary string:

binary('hello')

And returns the result new byte[] { 104, 101, 108, 108, 111 }.

bool

Return the Boolean version of a value.

bool(<value>)

ParameterRequiredTypeDescription
<value>YesanyThe value to convert
Return valueTypeDescription
true or falseBooleanThe Boolean version of the specified value

Example

These examples convert the specified values to Boolean values:

bool(1)
bool(0)

And respectively returns these results:

  • true
  • false

ceiling

Return the largest integral value less than or equal to the specified number.

ceiling('<number>')

ParameterRequiredTypeDescription
<number>YesnumberAn input number
Return valueTypeDescription
<integer-value>integerThe largest integral value greater than or equal to the input number

Example

This example returns the largest integral value less than or equal to the number 10.333:

ceiling(10.333)

And returns the integer 11.

coalesce

Return the first non-null value from one or more parameters. Empty strings, empty arrays, and empty objects are not null.

coalesce(<object**1>, <object**2>, ...)

ParameterRequiredTypeDescription
<object1>, <object2>, ...YesanyOne or more items to check for null. Mixed types are acceptable.
Return valueTypeDescription
<first-non-null-item>anyThe first item or value that isn't null. If all parameters are null, this function returns null.

Example

These examples return the first non-null value from the specified values, or null when all the values are null:

coalesce(null, true, false)
coalesce(null, 'hello', 'world')
coalesce(null, null, null)

And respectively return:

  • true
  • hello
  • null

concat

Combine two or more objects, and return the combined objects in a list or string.

concat('<text1>', '<text2>', ...)

ParameterRequiredTypeDescription
<object1>, <object2>,...YesanyAt least two objects to concat.
Return valueTypeDescription
`<object1object2...>`string or listThe combined string or list. Null values are skipped.

Expected return values:

  • If all items are lists, a list will be returned.
  • If there exists an item that isn't a list, a string will be returned.
  • If a value is null, it's skipped and not concatenated.

Example

This example combines the strings Hello and World:

concat('Hello', 'World')

And returns the result HelloWorld.

Example 2

This example combines the lists [1,2] and [3,4]:

concat([1,2],[3,4])

And returns the result [1,2,3,4].

Example 3

These examples combine objects of different types:

concat('a', 'b', 1, 2)
concat('a', [1,2])

And return the following results respectively:

  • The string ab12.
  • The object aSystem.Collections.Generic.List 1[System.Object]. This is unreadable and best to avoid.

Example 4

These examples combine objects will null:

concat([1,2], null)
concat('a', 1, null)

And return the following results respectively:

  • The list [1,2].
  • The string a1.

contains

Check whether a collection has a specific item. Return true if the item is found, or return false if not found. This function is case-sensitive.

contains('<collection>', '<value>')
contains([<collection>], '<value>')

This function works on the following collection types:

  • A string to find a substring
  • An array to find a value
  • A dictionary to find a key
ParameterRequiredTypeDescription
<collection>Yesstring, array, or dictionaryThe collection to check
<value>Yesstring, array, or dictionary, respectivelyThe item to find
Return valueTypeDescription
true or falseBooleanReturn true if the item is found. Return false if not found.

Example 1

This example checks the string hello world for the substring world:

contains('hello world', 'world')

And returns the result true.

Example 2

This example checks the string hello world for the substring universe:

contains('hello world', 'universe')

And returns the result false.

count

Return the number of items in a collection.

count('<collection>')
count([<collection>])

ParameterRequiredTypeDescription
<collection>Yesstring or arrayThe collection with the items to count
Return valueTypeDescription
<length-or-count>integerThe number of items in the collection

Examples:

These examples count the number of items in these collections:

count('abcd')
count(createArray(0, 1, 2, 3))

And both return the result 4.

countWord

Return the number of words in a string

countWord('<text>')

ParameterRequiredTypeDescription
<text>YesstringThe string to count
Return valueTypeDescription
<count>integerThe number of words in the string

Example

This example counts the number of words in the string hello world:

countWord("hello word")

And it returns the result 2.

convertFromUTC

Convert a timestamp in an optional locale format from Universal Time Coordinated (UTC) to a target time zone.

convertFromUTC('<timestamp>', '<destinationTimeZone>', '<format>'?, '<locale>'?)

ParameterRequiredTypeDescription
<timestamp>YesstringThe string that contains the timestamp
<destinationTimeZone>YesstringThe name of the target time zone. Supports Windows and IANA time zones.
<format>NostringA custom format pattern. Default: "o" format, yyyy-MM-ddTHH:mm:ss.fffffffK, which complies with ISO 8601.
<locale>NostringAn optional locale of culture information
Return valueTypeDescription
<converted-timestamp>stringThe timestamp converted to the target time zone

Examples:

These examples convert from UTC to Pacific Standard Time:

convertFromUTC('2018-02-02T02:00:00.000Z', 'Pacific Standard Time', 'MM-DD-YY')
convertFromUTC('2018-02-02T02:00:00.000Z', 'Pacific Standard Time')

And respectively return these results:

  • 02-01-18
  • 2018-01-01T18:00:00.0000000

Example 2

This example converts a timestamp in the en-US locale from UTC to Pacific Standard Time:

convertFromUTC('2018-01-02T02:00:00.000Z', 'Pacific Standard Time', 'D', 'en-US')

And returns the result Monday, January 1, 2018.

convertToUTC

Convert a timestamp in an optional locale format to Universal Time Coordinated (UTC) from the source time zone.

convertToUTC('<timestamp>', '<sourceTimeZone>', '<format>'?, '<locale>'?)

ParameterRequiredTypeDescription
<timestamp>YesstringThe string that contains the timestamp
<sourceTimeZone>YesstringThe name of the source time zone. Supports Windows and IANA time zones.
<format>NostringA custom format pattern. Default: UTC ISO format YYYY-MM-DDTHH:mm:ss.fffZ, which complies with ISO 8601.
<locale>NostringAn optional locale of culture information
Return valueTypeDescription
<converted-timestamp>stringThe timestamp converted to the target time zone

Example

This example converts a timestamp to UTC from Pacific Standard Time

convertToUTC('01/01/2018 00:00:00', 'Pacific Standard Time')

And returns the result 2018-01-01T08:00:00.000Z.

Example 2

This example converts a timestamp in the de-DE locale to UTC from Pacific Standard Time:

convertToUTC('01/01/2018 00:00:00', 'Pacific Standard Time', '', 'de-DE')

And returns the result 01.01.18 08:00:00.

createArray

Return an array from multiple inputs.

createArray('<object1>', '<object2>', ...)

ParameterRequiredTypeDescription
<object1>, <object2>,...Yesany, but not mixedAt least two items to create the array
Return valueTypeDescription
[<object1>, <object2>, ...]arrayThe array created from all the input items

Example

This example creates an array from the following inputs:

createArray('h', 'e', 'l', 'l', 'o')

And returns the result [h ,e, l, l, o].

dataUri

Return a data uniform resource identifier (URI) of a string.

dataUri('<value>')

ParameterRequiredTypeDescription
<value>YesstringThe string to convert
Return valueTypeDescription
[<date-uri>]stringThe data URI for the input string

Example

dataUri('hello')

Returns the result data:text/plain;charset=utf-8;base64,aGVsbG8=.

dataUriToBinary

Return the binary version of a data uniform resource identifier (URI).

dataUriToBinary('<value>')

ParameterRequiredTypeDescription
<value>YesstringThe data URI to convert
Return valueTypeDescription
[<binary-for-data-uri>]byte arrayThe binary version of the data URI

Example

This example creates a binary version for the following data URI:

dataUriToBinary('aGVsbG8=')

And returns the result new byte[] { 97, 71, 86, 115, 98, 71, 56, 61 }.

dataUriToString

Return the string version of a data uniform resource identifier (URI).

dataUriToString('<value>')

ParameterRequiredTypeDescription
<value>YesstringThe data URI to convert
Return valueTypeDescription
[<string-for-data-uri>]stringThe string version of the data URI

Example

This example creates a string from the following data URI:

dataUriToString('data:text/plain;charset=utf-8;base64,aGVsbG8=')

And returns the result hello.

date

Return the date of a specified timestamp in m/dd/yyyy format.

date('<timestramp>')

ParameterRequiredTypeDescription
<timestamp>YesstringThe string that contains the timestamp
Return valueTypeDescription
<date>stringThe date of the specified timestamp
date('2018-03-15T13:00:00.000Z')

Returns the result 3-15-2018.

dateReadBack

Uses the date-time library to provide a date readback.

dateReadBack('<currentDate>', '<targetDate>')

ParameterRequiredTypeDescription
<currentDate>YesstringThe string that contains the current date
<targetDate>YesstringThe string that contains the target date
Return valueTypeDescription
<date-readback>stringThe readback between current date and the target date

Example 1

dateReadBack('2018-03-15T13:00:00.000Z', '2018-03-16T13:00:00.000Z')

Returns the result tomorrow.

dateTimeDiff

Return the difference in ticks between two timestamps.

dateTimeDiff('<timestamp1>', '<timestamp2>')

ParameterRequiredTypeDescription
<timestamp1>YesstringThe first timestamp string to compare
<timestamp2>YesstringThe second timestamp string to compare
Return valueTypeDescription
<ticks>numberThe difference in ticks between two timestamps

Example 1

This example returns the difference in ticks between two timestamps:

dateTimeDiff('2019-01-01T08:00:00.000Z','2018-01-01T08:00:00.000Z')

And returns the number 315360000000000.

Example 2

This example returns the difference in ticks between two timestamps:

dateTimeDiff('2018-01-01T08:00:00.000Z', '2019-01-01T08:00:00.000Z')

Returns the result -315360000000000. The value is a negative number.

dayOfMonth

Return the day of the month from a timestamp.

dayOfMonth('<timestamp>')

ParameterRequiredTypeDescription
<timestamp>YesstringThe string that contains the timestamp
Return valueTypeDescription
<day-of-month>integerThe day of the month from the specified timestamp

Example

This example returns the number for the day of the month from the following timestamp:

dayOfMonth('2018-03-15T13:27:36Z')

And returns the result 15.

dayOfWeek

Return the day of the week from a timestamp.

dayOfWeek('<timestamp>')

ParameterRequiredTypeDescription
<timestamp>YesstringThe string that contains the timestamp
Return valueTypeDescription
<day-of-week>integerThe day of the week from the specified timestamp. Sunday is 0, Monday is 1, and so forth.

Example

This example returns the number for the day of the week from the following timestamp:

dayOfWeek('2018-03-15T13:27:36Z')

And returns the result 3.

dayOfYear

Return the day of the year from a timestamp.

dayOfYear('<timestamp>')

ParameterRequiredTypeDescription
<timestamp>YesstringThe string that contains the timestamp
Return valueTypeDescription
<day-of-year>integerThe day of the year from the specified timestamp

Example

This example returns the number of the day of the year from the following timestamp:

dayOfYear('2018-03-15T13:27:36Z')

And returns the result 74.

div

Return the integer result from dividing two numbers. To return the remainder see mod().

div(<dividend>, <divisor>)

ParameterRequiredTypeDescription
<dividend>YesnumberThe number to divide by the divisor
<divisor>YesnumberThe number that divides the dividend. Can't be 0.
Return valueTypeDescription
<quotient-result>numberThe result from dividing the first number by the second number

Example

Both examples divide the first number by the second number:

div(10, 5)
div(11, 5)

And return the result 2.

There exists some gap between Javascript and .NET SDK. For example, the following expression will return different results in Javascript and .NET SDK:

If one of the parameters is a float, the result will also be a FLOAT with .NET SDK.

Example

div(11.2, 2)

Returns the result 5.6.

If one of the parameters is a float, the result will be an INT with Javascript SDK.

Example

div(11.2, 2)

Returns the result 5.

The workaround for Javascript to keep a certain number of decimal places in results is to use such expression. For example, to keep 3 decimal places:

float(concat(string(div(a, b)),'.',string(mod(div(a*1000, b), 1000))))