# Expression Language reference

An expression comprises two main elements, **functions** and **operators**. These are then structured around brackets to create a custom formula:
  
- [Functions] - The part of the data that is to be operated on including **profile attributes** and **constants**. These are then processed using functions. Learn more [here](https://www.infobip.com/docs/expression-language/expression-language-reference#functions).
- [Operators] - determine the action to be performed and can be **arithmetic**, **logical**, or a **comparison**. Learn more [here](https://www.infobip.com/docs/expression-language/expression-language-reference#operators).
- [Brackets] - these determine the order of operations and allow for the grouping of functions and operators to build complex, custom formulas. Learn more [here](https://www.infobip.com/docs/expression-language/expression-language-reference#brackets).

As an example, you could use a formula to calculate the conversion rate of an email campaign if you are capturing emails sent and emails clicked data. The custom formula would look something like this:
  
`round(100*(email_link_clicks/emails_sent),0)`

## Functions
  
A function is a pre-defined process that is run against constants and profile attributes to perform a complex task such as:

- Rounding or comparing numbers
- Formatting text or timestamps
- Date manipulation

You can use functions whenever you are building your formula in the web interface.
  
The following functions are available:

- [String functions](https://www.infobip.com/docs/expression-language-reference#string-functions)
- [Date/time functions](https://www.infobip.com/docs/expression-language-reference#date-time-functions)

## String functions

### Len [#len-string-functions]

The `len` function returns the length of a string or profile attribute. This may be useful if you would like to evaluate if a string or profile attribute has an appropriate length.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| len(stringValue) | String | Integer | `len("infobip.com")`Output: `11` |

### Find [#find-string-functions]

The `find` function returns the position of a substring inside a string as a whole number. This is useful if you are looking to find a subset of data inside a string or profile attribute. This function is **case sensitive**.
  
`find()` is zero-based (offset), meaning that it is indexed from 0. If the `find()` function matches the entry at the beginning of a string then the output will be `0`.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| find(stringValue, search) | String, String | Integer | The `firstName` attribute of a profile for a user called Andrea:`find(First Name, "a")` will output the number5for Andrea`find(First Name, "A")` will output0forAndrea.If no substring is matched using the `find()` function, then the output will be -1`find(First Name, "b")` will output `-1` for Andrea |

### Replace [#replace-string-functions]

The `replace` function is a part of a string that contains an old value with a new value.
  
As a simple example, `replace( "Good morning", "morning", "afternoon")` would output `Good afternoon`.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| replace(stringValue, oldValue, newValue) | String, String, String | String | `replace( "I love cats", "cats", "dogs")`Output: `I love dogs` |

### Trim [#trim-string-functions]

The `trim` function trims spaces, newlines, and tabs from both ends of a string.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| trim(stringValue) | String | String | `trim(" abc ")`Output: `abc` |

### Left [#left-string-functions]

The `left` function returns a **count** of the first characters from a string or profile attribute. This is useful if you want to return the first characters from a profile attribute or string of text.
  
For example, `left(city ,4)`. If the `city` attribute is London then the output would return the first 4 characters of London: `Lond`.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| left(stringValue, count) | String, Integer | String | `left("I love cats",5)`Output: `I lov` |

### Right [#right-string-functions]

The `right` function returns a **count** of the last characters from a string or profile attribute. This is useful if you want to return the last characters from a profile attribute or string of text.
  
To use a simple example, `right(city ,4)`. If the `city` attribute is London then the output would return the last 4 characters of London: `ndon`.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| right(stringValue, count) | String, Integer | String | `right("I love cats",4)`Output: `cats` |

### Mid [#mid-string-functions]

The `mid` function returns a **count** of characters from a string or profile attribute starting from a chosen **offset** value. This is useful if you want to return the exact number of characters from the middle of a string or profile attribute.
  
This function is zero-based (offset), meaning that it is indexed from 0. Be sure to take this into account when you are defining the offset parameters to define where the count should start.
  
For example, `mid(city,2,3)`. If the `city` attribute is London then the output will be `ndo` because offset is 2 and character count is 3.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| mid(stringValue, offsetValue, countValue) | String, Integer, Integer | String | `mid("I love cats",2,4)`Output: `love` |

### Concatenate [#concatenate-string-functions]

The `concatenate` function returns the concatenated string. This is useful if you would like to combine multiple strings or profile attributes into a single output.
  
A simple example would be to combine a persons first name (`firstName` attribute) and last name (`lastName` attribute) into a single result if you ever need to capture their full name for marketing purposes.
  
Use `concat(First Name, " ", Last Name)` for this example. If the `firstName` attribute is Edward and `lastName` attribute is Jones, then the output would be `Edward Jones`.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| concat(stringValue 1, stringValue 2, stringValue n...) | String, String, String, ... n; | String | `concat("I", " Love ", "Cats")`Output: `I Love Cats` |

### Contains [#contains-string-functions]

The `contain` function is a text search within a string (appears somewhere inside the string). Use `contains()` to identify case sensitive text from within a larger body of text.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| contains(stringValue, search) | String, String | Boolean | `contains("CAT,dad,Frog,doggybag,hotdog","dog")`Output: `True``contains("CAT,Frog,doggybag,hotdog","bird")`Output: `False` |

### Starts with [#starts-with-string-functions]

Use the `startsWith()` function to determine whether a string starts with the characters of a particular string.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| startsWith(stringValue, search) | String, String | Boolean | `startsWith("Josephine","Jo")`Output: `True` |

### Ends with [#ends-with-string-functions]

Use the `endsWith()` function to determine whether a string ends with the characters of a particular string.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| endsWith(stringValue, search) | String, String | Boolean | `endsWith("Josephine","Jo")`Output : `False` |

### leftPad [#leftpad-string-functions]

Use the `leftPad` function to pad to the left of the original string with a padding string. The size integer specifies how many characters the new value should be, including the original string.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| leftPad(original string, size integer, padding string) | String, Integer, String | String | `leftPad("15", 6, "0")`Output: `000015``leftPad("15", 7, "02")`Output: `0202015` |

## Date/Time functions  

### Now [#now-date-time-functions]

Use the `now()` function to return the current `DateTime` in UTC format.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| now() | - | DateTime | `now()`Output: `YYYY-MM-DD THH:mm:ssZ`; e.g., 2009-09-24T11:34:56Z |

### Today [#today-date-time-functions]

Use the `today()` function to return todays date (without time) in the `Date` format by default. You can include the optional timezone parameter by adding following format to your expression:
  
- `+h`
- `+hh`
- `+hh:mm`
- `-hh:mm`
- `+hhmm`
- `-hhmm`
- `+hh:mm:ss`
- `-hh:mm:ss`
- `+hhmmss`
- `-hhmmss`
  
For example, `today("-0600")` would set the timezone to **-6 hours**.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| today() | - / String | Date | `today()``today("+2")``today("-0230")``today("+02:30")`Output: `YYYY-MM-DD` |

### Date add [#date-add-date-time-functions]

Use `addDays/addMonths`, etc., to add an integer amount to a date or time.
  
`addHours`, `addMinutes`, and `addSeconds` operators output in `Date Time`. Other `addDate` operators output `Date Time/Date`. You can subtract time by applying a minus integer in your expression.
  
For example, `adddays(todatetime("2009-09-24","yyyy-MM-dd"), -4)` would output: `2009-09-20 00:00:00`
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| addDays(dateTimeValue, amount),addHours(dateTimeValue, amount),addMinutes(dateTimeValue, amount),addSeconds(dateTimeValue, amount),addWeeks(dateTimeValue, amount),addMonths(dateTimeValue, amount),addQuarters(dateTimeValue, amount),addYears(dateTimeValue, amount) | DateTime or Date, Integer | DateTime or Date | `addDays(toDate("2009-09-24", "yyyy-MM-dd"), 4)`Output: `2009-09-28``addDays(toDate("2009-09-24", "yyyy-MM-dd"), -4)`Output: `2009-09-20` |

### Date diff [#date-diff-date-time-functions]

The `dateDiff` function returns the difference between `dt1` and `dt2` date/datetime profile attributes as a decimal. The output result is in days by default.
  
You can set optional parameter modes to change the output to years, months, days, hours or seconds by including a string input.
  
This function is extremely powerful for calculating date differences relating to different events. Perhaps you would like to see the date difference between a user making a first order and when they completed last order or the date difference between purchase date and delivery date.
  
For example, `dateDiff(firstOrderDate, lastOrderDate)` would return the difference in days between the two dates.
  
`dateDiff(firstOrderDate, lastOrderDate, "hours")` would return the result in hours, and `dateDiff(firstOrderDate, lastOrderDate, "minutes")` would return the result in minutes.
  
If you need the output to be a whole number, use the `round()` function to round the decimal number.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| dateDiff(dateValue 1, dateValue 2, [string]) | DateTime or Date, DateTime or Date, String | Decimal | `dateDiff(toDateTime("2016-01-12 01:08:12", "yyyy-M-d HH:mm:ss")``toDateTime("2017-01-12 01:08:12", "yyyy-M-d HH:mm:ss"), "years")`Output: `1``dateDiff(toDate("2016-01-12", "yyyy-M-d")``toDate("2016-01-11", "yyyy-M-d"), "hours")`Output: `24``dateDiff(toDate("2016-01-12", "yyyy-M-d")``toDateTime("2016-01-12 00:10:00", "yyyy-M-d HH:mm:ss")"minutes")`Output: `10`The `toDate` or `toDateTime` functions are not currently available for use in People. Use `dateDiff` with attributes like `dateDiff(Purchase Date, Delivery Date)` |

### Year [#year-date-time-functions]

The `year` function returns the year for a `dt` date/datetime profile attribute. This is useful if you would like to return only the year of a date/datetime profile attribute and then use it to create milestone marketing events around the year of birth.
  
For example, if the `Birth Date` attribute is `04/12/1974`. `year(Birth Date)` expression would output `1974`.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| year(dateTimeValue) | DateTime or Date | Integer | `year(toDate("1981-07-12", "yyyy-MM-dd"))`Output: `1981`The `toDate` or to `DateTime` functions are not currently available for use in People. Use `year` with profile attributes like `year(Birth Date)` to show the year of birth. |

### Quarter [#quarter-date-time-functions]

The `quarter` function returns the calendar quarter (1-4) for a `dt` date/datetime profile attribute. This is useful if you would like to filter profile attributes by the calendar quarter (i.e., Q1 to Q4) and then target those profiles with particular marketing communications.

For example, if the `purchaseDate` attribute is `04/12/2020` then the output of quarter (purchaseDate) would be `4`.

| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| quarter(dateTimeValue) | DateTime or Date | Integer | `quarter(toDate("1981-07-12", "yyyy-MM-dd"))`Output: `3`The `toDate` or `toDateTime` functions are not currently available for use in People. Use `quarter` with profile attributes like `quarter(Birth Date)` to show which quarter the birthday falls on. |

### Month [#month-date-time-functions]

The `month` function returns the month as a whole number (1-12) for a `dt` date/datetime profile attribute.
  
For example, if a user's `Birth Date` attribute is `04/12/1974`, then the expression `month(Birth Date)` would output `12`.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| month(dateTimeValue) | DateTime or Date | Integer | `month(toDate("1981-07-12", "yyyy-MM-dd"))`Output: `7`The `toDate` or `toDateTime` functions are not currently available for use in People. Use `month` with profile attributes like `month(Birth Date)` to show which month the birthday falls on. |

### Day [#day-date-time-functions]

Returns the day (1-31) for a `dt` date/datetime profile attribute.
  
For example, if a user's `Birth Date` attribute is `04/12/1974`, then the expression `day(Birth Date)` would output `4`.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| day(dateTimeValue) | DateTime or Date | Integer | `day(toDate("1981-07-12", "yyyy-MM-dd"))`Output: `12`The `toDate` or `toDateTime` functions are not currently available for use in People. Use `day` with profile attributes like `day(Birth Date)` to show which day the birthday falls on. |

### Hour [#hour-date-time-functions]

The `hour` function returns the hour part of a `dt datetime` profile attribute. This is useful for delivery or purchase related profile attributes.
  
For example, if you have a profile attribute called `deliveryDate` you could run the expression `hour(deliveryDate)` to output the hour of delivery for a product or item.
  
If `deliveryDate` is `2020-07-12 11:22:56`, then the output would be `11`.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| hour(dateTimeValue) | DateTime | Integer | `hour(toDateTime("1981-07-12 11:22:56", "yyyy-M-d HH:mm:ss"))`Output: `11`The `toDate` or `toDateTime` functions are not currently available for use in People. Use `hour` with `date` and `time` attributes like `hour(Last Purchase Date)` to show which hour the purchase was made. |

### Minute [#minute-date-time-functions]

The `minute` function returns the minute of a given (date)time or profile attribute.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| minute(dateTimeValue) | DateTime | Integer | `minute(toDateTime("1981-07-12 12:34:56", "yyyy-M-d HH:mm:ss"))`Output: `34` |

### Second [#second-date-time-functions]

The `second` function returns the second of a given (date)time (or profile attribute).
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| second(dateTimeValue) | DateTime | Integer | `second(toDateTime("1981-07-12 12:34:56", "yyyy-M-d HH:mm:ss"))`Output: `56` |

### Day of year [#day-of-year-date-time-functions]

The `dayofYear` function returns the day of the year for a `dt date/datetime` profile attribute, where the count starts on January 1st and ends on the date set. This is useful for purchases or delivery related profile attributes and building campaigns around a particular day of the year, e.g., New Year's Day or Black Friday.
  
For example, if the `purchaseDate` attribute is `2020-07-12 11:22:56` then the `dayOfYear(purchaseDate)` output would be `193`.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| dayOfYear(dateTimeValue) | DateTime or Date | Integer | `dayOfYear(toDate("2021-10-12", "yyyy-M-d"))`Output: `193`The `toDate` or `toDateTime` functions are not currently available for use in People. Use `dayOfYear` with date time attributes like `dayOfYear(Last Purchase Date)` to show which day of the year the last purchase was made. |

### Day of week [#day-of-week-date-time-functions]

The `dayofWeek` function returns the day of the week (1-7) for the `dt date/datetime` profile attribute, where Monday is 1 and Sunday is 7.
  
For example, if the `deliveryDate` attribute is `2020-07-12 11:22:56` then the expression `dayOfWeek(deliveryDate)` will be `3`.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| dayOfWeek(dateTimeValue) | DateTime or Date | Integer | `dayOfWeek(toDate("2021-10-12", "yyyy-M-d"))`Output: `3`The `toDate` or `toDateTime` functions are not currently available for use in People. Use `dayOfWeek` with date time attributes like `dayOfWeek(Last Purchase Date)` to show which day of the week the last purchase was made. |

### Format date time [#format-date-time-date-time-functions]

The `formatDateTime` function takes `date time` as input and returns string with formatted `date time`. The user setup requires a format specified as the second attribute, with support for unix format. Additional formats can be defined by the user based on masks and components.

- **d:** The day of the month, from 1 to 31.
- **dd**: The day of the month, from 01 to 31.
- **eee:** Day of the week abbreviated.
- **eeee**: The full name of the day of the week.
- **h**: The hour, 12-hour clock from 1 to 12.
- **hh**: The hour,12-hour clock from 01 to 12.
- **H:** The hour, 24-hour clock from 0 to 23.
- **HH**: The hour, 24-hour clock from 00 to 23.
- **m**: The minute, from 0 to 59.
- **mm**: The minute, from 00 to 59.
- **M**: The month, from 1 to 12.
- **MM**: The month, from 01 to 12.
- **MMM**: Name of the month abbreviated.
- **MMMM**: The full name of the month.
- **s:** The second, from 0 to 59.
- **ss**: The second, from 00 to 59.
- **a**: AM/PM designator.
- **y**: The year as a four-digit number.
- **yy**: The year, from 00 to 99.
- **yyyy**: The year as a four-digit number.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| formatDateTime(dateTimeValue, formatValue) | DateTime or Date | Integer | `formatDateTime(toDateTime("2021-08-03 14:05:13", "yyyy-M-d HH:mm:ss"), "unix")`Output: `1627988713``formatDateTime(toDateTime("2021-08-03 14:05:13", "yyyy-M-d HH:mm:ss"), "dd-MM-yy h:mm a eee")`Output: `03-08-21 2:05 PM Tue`The `toDate` or `toDateTime` functions are not currently available for use in People. |

### Format date [#format-date-date-time-functions]

The `formatDate` function takes `date` as an input and returns a string with the date formatted according to the user's needs. The desired format needs to be added as a second attribute. The user can define other formats according to mask and components.
  
- **d**: The day of the month, from 1 to 31.  
- **dd**: The day of the month, from 01 to 31.  
- **eee**: The abbreviated name of the day of the week.  
- **eeee**: The full name of the day of the week.  
- **M**: The month, from 1 to 12.  
- **MM**: The month, from 01 to 12.  
- **MMM**: The abbreviated name of the month.  
- **MMMM**: The full name of the month.  
- **y**: The year as a four-digit number.  
- **yy**: The year, from 00 to 99.  
- **yyyy**: The year as a four-digit number.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| formatDate(date, formatValue) | Date, String | String | `formatDate(toDate("2007-04-05", "yyyy-MM-dd"), "dd.MM.yyyy")`Output: `05.04.2007``formatDate(toDate("05/04/2007", "dd/MM/yyyy"), "yyyy-MM-dd")`Output: `2007-04-05`The `formatDate` function is not currently available for use in People. |

## Operators  

You can use `operators` to perform calculations and comparisons within custom formulas. This is very useful in scenarios if you would like to run calculations against values, e.g., adding up scores or counting the number of times a user has interacted with your service.
  
You can use the following operators:

- **[Arithmetic](https://www.infobip.com/docs/expression-language-reference#arithmetic-operators)**: Abs, +, -, /, *, Modulo %, Round, Floor
- **[Logical](https://www.infobip.com/docs/expression-language-reference#logical-operators)**: AND, OR, NOT, >, <, >=, ==, !=
- **[Conversion](https://www.infobip.com/docs/expression-language-reference#conversion-operators)**: toInt, toDecimal, toDate, toTime, toDateTime, toString, toBool
- **[Other](https://www.infobip.com/docs/expression-language-reference#other-operators)**: generatePin

## Arithmetic operators

### Abs [#abs-arithmetic-operators]

Returns the absolute value of a given number or profile attribute.
  
For example, both `abs(5)` and `abs(-5)` functions would output `5`.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| abs(decimalValue) | Decimal or Integer | Decimal or Integer (dependent on input data type) | `abs(5)`Output: `5``abs(-5)`Output: `5` |

### Add [#add-arithmetic-operators]

Add values together using `+`.
  
For example, the expression `1 + 2 + 3` would output `6`.

| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| + | Decimal or Integer | Decimal or Integer (dependent on input data type) | `1 + 2 + 3`Output: `6` |

### Subtract [#subtract-arithmetic-operators]

Subtract values from another value using `-`.
  
For example, the expression `5 - 3` would output `2`.

| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| - | Decimal or Integer | Decimal or Integer (dependent on input data type) | `5 - 3`Output: `2` |

### Divide [#divide-arithmetic-operators]

Divides values using `/`.
  
For example, the expression `4 / 2` would output `2`.

| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| / | Decimal or Integer | Decimal or Integer (dependent on input data type) | `4 / 2`Output: `2` |

### Multiply [#multiply-arithmetic-operators]

Multiplies values using `*`.
  
For example, the expression `2 * 2` would output `4`.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| x | Decimal or Integer | Decimal or Integer (dependent on input data type) | `2 * 2`Output: `4` |

### Modulo [#modulo-arithmetic-operators]

Returns the `modulo` (remainder) of a divided value.
  
For example, the expression `12 % 8` would output `4`.

| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| % | Decimal or Integer | Decimal or Integer (dependent on input data type) | `12 % 8`Output: `4` |

### Round [#round-arithmetic-operators]

Returns the value of `num` rounded to the nearest value with digits after the decimal point. **Scale** the number of decimal points within the expression, and round to the nearest whole number.
  
For example, the expression `round(1.23456, 3)` would round up to 3 decimal places. The result is `1.235`.

| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| round(decimalValue, scale) | Decimal or Integer, Integer | Decimal or Integer (dependent on input data type) | `round(1.23456,3)`Output: `1.235` |

### Floor [#floor-arithmetic-operators]

Returns the value of `num` rounded down to the nearest integer value.
  
The expression `floor(1.2345)` would output `1`.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| floor(decimalValue) | Decimal or Integer | Decimal or Integer (dependent on input data type) | `floor(1.2345)`Output: `1` |

### Ceil [#ceil-arithmetic-operators]

Returns the value of `num` rounded up to the nearest integer value.
  
The expression `ceil(1.7)` would output `2`.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| ceil(decimalValue) | Decimal or Integer | Decimal or Integer (dependent on input data type) | `ceil(1.7)`Output: `2` |

## Logical operators  

### Equal [#equal-logical-operators]

The `==` operator is used to evaluate if two values are equal and output `True` or `False` depending on the result.
  
As a simple example, `5 == 5` would output to `True` and `First Name == Last Name` would output to `False`.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| == | Any input data type | Boolean | `A == A`Output: `True` |

### Not equal [#not-equal-logical-operators]

The `!=` operator is used to evaluate if two values are not equal, and output `True` or `False` depending on the result.
  
As a simple example, `5 != 5` would output to `False` and `First Name != Last Name` would output to `True`.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| != | Any input type | Boolean | "A" != "A"Output: `False` |

### Greater than [#greater-than-logical-operators]

The > operator is used to evaluate if a value is more than a different value and output `True` or `False` depending on the result.
  
As an example, 1 > 5 would output `False`.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| > | Decimal or Integer | Boolean | 1 > 5Output: `False` |

### Greater than or equal [#greater-than-or-equal-logical-operators]

The >= operator is used to evaluate if a value is more than or equal to another value, and output `True` or `False` depending on the result.
  
As an example, 1 >= 5 would output `False`.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| >= | Decimal or Integer | Boolean | 1 >= 5Output: `False` |

### Less than [#less-than-logical-operators]

The < operator is used to evaluate if a value is less than a different value, and output `True` or `False` depending on the result.
  
As an example, 1 < 5 would output `True`.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| < | Decimal or Integer | Boolean | 1 < 5Output: `True` |

### Less than or equal [#less-than-or-equal-logical-operators]

The <= operator is used to evaluate if a value is less than or equal to another value, and output `True` or `False` depending on the result.
  
As an example, 1 <= 5 would output `True`.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| <= | Decimal or Integer | Boolean (True / False) | 1 <= 5Output: `True` |

### And [#and-logical-operators]

The `and` operator returns `True` if both operands are `True`, and returns `False` otherwise. This is a very effective way of creating complex custom formulas when used with brackets to order precedence.
  
For example, the expression `(1==5) and (Gender=='m')` would output `False`.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| and | Boolean | Boolean | `(1==5) and (3==4)`Output: `False` |

### Or [#or-logical-operators]

The `or` operator returns `False` if both operands are `False`, and returns `True` otherwise.
  
An example expression could be `(5 ==5) or (Gender == "m")` which would output `True`.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| or | Boolean | Boolean | `(5 ==5) or (3==4)`Output: `True` |

### Not [#not-logical-operators]

The `not` operator is a Boolean operator that returns `True` when the operand is `False`, and returns `False` when the operand is `True`.
  
A simple example is `not(5==5)` which would output `False`.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| not | Boolean | Boolean | `not(5==5)`Output: `False` |

### If [#if-logical-operators]

The `if` function evaluates the Boolean expression passed as its first parameter, and, depending on the result, returns `option1` if true, or `option2` if false.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| if(predicate, option1, option2) | Boolean, option1 (data types: True/False/Date Time/Date/Decimal Number/Whole Number/Text), option2 (data types: True/False/Date Time/Date/Decimal Number/Whole Number/Text) | Output data type will be the same as the data type chosen at Input. | `if(Gender == "M", "Mr", (if(MaritalState== "Married", "Mrs", "Ms"))`Output: `Value is Mr if gender is M``Value is Mrs if gender is not M, and MaritalState is married.``Value is Ms if gender is not M, and MaritalState is not married.` |

### isEmpty [#isempty-logical-operators]

The `isEmpty` operator is a Boolean operator that returns true if an attribute/variable has no value, and returns false if an attribute/variable has a value.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| isEmpty(any) | Any input data type | Boolean | `isEmpty(BirthDate)`Output: `True`, if no value exists for the attribute/variable |

## Conversion operators  

### toInt [#toint-conversion-operators]

Converts a decimal, integer or string to integer.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| toInt(decimalValue) | Decimal or Integer or String | Integer | `toInt("123.345")`Output: `123toInt(NULL)` Output: `0` |

### toDecimal [#todecimal-conversion-operators]

Converts a decimal, integer or string to decimal.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| toDecimal( string text) | Decimal or Integer or String | Decimal | `toDecimal("123.345")`Output: `123.345` `toDecimal(NULL)` Output: `0` |

### toDate [#todate-conversion-operators]

Converts a string to a date format.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| toDate(stringValue, format) | String, String | Date | `toDate("2009-09-24","yyyy-MM-dd")`Output: `2009-09-24` |

### toDateTime [#todatetime-conversion-operators]

Converts a string to a date time format.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| toDateTime(stringValue, format) | String, String | DateTime | `toDateTime("2009-09-24 12:34:56","yyyy-MM-dd HH:mm:ss")`Output: `2009-09-24T11:34:56Z` |

### toString [#tostring-conversion-operators]

Converts any input data type to a string.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| toString(stringValue, format) | Any input data type | String | `toString(123)`Output: `123` |

### toBool [#tobool-conversion-operators]

Converts string text to a Boolean value.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| toBool(booleanValue) | String | Boolean | `toBool("TRUE")`Output: `True` |

## Other operators  

### Generate pin [#generate-pin-other-operators]

Generates a random sequence of alphanumeric symbols.
  
| Availability | Format | Input data type | Output data type | Example |
| --- | --- | --- | --- | --- |
| generatePin(lengthValue, isAlphanumeric) | Integer, Boolean | String | `generatePin(10,true)`Output: `ABCD43E5H4``generatePin(4,false)`Output: `6752` |

## Brackets  

You can use parentheses in complex, custom formulas to enforce the order of operators. This allows for the creation of highly complex formulas with limitless possibilities.