> For the complete documentation index, see [llms.txt](https://docs.xforms.co/xforms-manual/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xforms.co/xforms-manual/form-controls/expression-exp.md).

# Expression (exp)

## Settings

| Setting    | Value                                                                                                                                                                                                                                                   | Comment                      |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- |
| type       | "exp"                                                                                                                                                                                                                                                   |                              |
| format     | <p>For numeric values:<br>"type:decimals"<br>type can be $, %, # (number) or nothing<br>decimals: number of decimal places (default 2)<br><br>For date/time:</p><p>"type:format"</p><p>type D for date (ISO, US, CAN, MN) <br>type T for time (24H)</p> |                              |
| expression | the expression to be calculated. In the expression can use other field values by putting field ID in {}                                                                                                                                                 | example: {height} \* {width} |
|            |                                                                                                                                                                                                                                                         |                              |

### Functions

#### Time Difference

Calculates difference between start time value and end time value and returns the number based on requested unit

timeDiff({start-time-field}, {end-time-field}, 'unit')

* start-time-field: Date or Time field ID that contains start time
* end-time-field: Date or Time field ID that contains end time
* unit: one of the followings surrender by single quote
  * seconds
  * minutes
  * hours
  * days
  * months
  * years

Example: timeDiff({start\_time}, {end\_time}, 'hours')
