# Workflow Calculated Fields

<div id="bkmrk-"></div>In Workflows, there is a particularly powerful and complex **Action** called **Calculated Fields** which allows you to do operations on the values in the records you’re handling.

[![image.png](https://docs.kiyocrm.com/uploads/images/gallery/2025-05/scaled-1680-/RHsimage.png)](https://docs.kiyocrm.com/uploads/images/gallery/2025-05/RHsimage.png)

## Adding Parameters

It is possible to add parameters to the formulas by using the dropdown in the Parameters section of the Calculate Fields’s user interface. The dropdown contains all of the (basic and custom) fields which belongs to the module selected in the basic fields section.

To add a parameter, select the field from the dropdown and click **Add Parameters** After this action, a new line appears in the parameter table with the name of the field and the given identifier.

For some fields (dropdowns and multi-selects) an additional dropdown shown up where the user can select if the raw or the formatted value should be used in Calculated Fields. The raw format means the value which is stored in the database and the formatted value means the label for that database value.

To remove a parameter from the table, simply click the **'-'** in the row of the parameter. Be aware, that if you remove a parameter, all of the identifiers are recalculated, so the identifiers could change for fields!

[![image.png](https://docs.kiyocrm.com/uploads/images/gallery/2025-05/scaled-1680-/Djkimage.png)](https://docs.kiyocrm.com/uploads/images/gallery/2025-05/Djkimage.png)

The identifier is used to reference this field when the user creates the formula. For example, all appearances of the {P0} identifier will be replaced with the Company’s name in the formula. All parameters are like {Px} where x is the sequential order of the parameter. The amount of the parameters is not limited.

## Adding Relation Parameters

Relation parameters are very similar to the regular parameters; the only difference is that the user first selects an entity which is in a one-to-one or one-to-many relationship with the actual entity.

To add a relation parameter, select the relation first, and then select the field from the connected entity and push the Add relation parameter button. After this action, a new line appears in the relation parameter table with the name of the relationship, the name of the field and the given identifier.

As for parameters for some relation parameter fields (dropdowns and multi-selects) an additional dropdown shown up where the user can select if the raw or the formatted value should be used in Calculate Fields.

To remove a relation parameter from the table, simply click on the '**-**' button in the row of the relation parameter. Be aware, that if you remove a relation parameter, all of the identifiers are recalculated, so the identifiers could change for fields!

[![image.png](https://docs.kiyocrm.com/uploads/images/gallery/2025-05/scaled-1680-/6xdimage.png)](https://docs.kiyocrm.com/uploads/images/gallery/2025-05/6xdimage.png)

The identifier is used to reference this field when the user creates the formula. For example, all appearances of the {R0} identifier will be replaced with the creator user‘s username in the formula. All relation parameters are like {Rx} where x is the sequential order of the relation parameter. The amount of the relation parameters is not limited.

## Creating Formula for a Field

In the Formulas part of the user interface the user can add formulas for fields of the actual entity.

To add a formula, select a field from the dropdown first and then push the Add formula button. After this action, a new line appears in the formula table with the name of the field and with the place for the formula.

To remove a formula from the table, simply click on the '**-**' in the row of the formula.

[![image.png](https://docs.kiyocrm.com/uploads/images/gallery/2025-05/scaled-1680-/Qnlimage.png)](https://docs.kiyocrm.com/uploads/images/gallery/2025-05/Qnlimage.png)

The formula is a textbox where the user can write the formulas. The module evaluates the formula on the given time (on save, on scheduler run or both) and fills the selected field with the evaluated value.

The formula can contain any text (with full UTF-8 support), but only the function parts (functions with parameters between ‘{‘and ‘}’) are evaluated. For example, and with the parameters added in the previous sections, if we fill the formula like: Company {P0} created by username {R0}, then the description field will have the following value after save: Company My Company created by username My User (implying the Company’s name is My Company and the creator user’s username is My User).

The Calculate Fields has many built-in functions which allows the user to build complex formulas to achieve various goals. These functions are described in the next section.

## Available Functions

As it is mentioned above, all of the functions are wrapped between <span style="font-family: Lucida Console, DejaVu Sans Mono, Ubuntu Mono, Monaco, monospace;"><span style="font-size: 11.76px; white-space-collapse: preserve; background-color: rgb(248, 248, 248);">{and}</span></span> signs, and they look like `{function Name (parameter1; parameter2; …)}`. The count of the parameters is different for the different functions. The module evaluates the functions and changes them with their result in the formula.

The functions can be embedded into each other (using a result of a function as a parameter for another function) like in this example:

<div class="sect1" id="bkmrk--5"><div class="sectionbody"><div class="paragraph">  
</div><div class="literalblock"><div class="content">  
</div></div></div></div>```
{power({subtract({divide({add({multiply(10; 2)}; 12)}; 8)}; 1)}; 2)}
```

<div class="sect1" id="bkmrk--6"><div class="sectionbody"><div class="literalblock"><div class="content">  
</div></div><div class="paragraph">  
</div></div></div>This function is the formalized look of the following mathematical expression:

<div class="sect1" id="bkmrk--7"><div class="sectionbody"><div class="paragraph">  
</div><div class="literalblock"><div class="content">  
</div></div></div></div>```
((((10 * 2) + 12) / 8) – 1)2
```

<div class="sect1" id="bkmrk--8"><div class="sectionbody"><div class="literalblock"><div class="content">  
</div></div><div class="paragraph">  
</div></div></div>The functions are divided to six groups. These groups are described in the next section of the document.

### Logical Functions

Logical functions are returning true or false in the form of 1 and 0 so checkboxes typed fields can be filled with these functions. They can be also used as the logical condition for the ifThenElse function.

#### equal

<div class="sect1" id="bkmrk-signature-%7Bequal%28par"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{equal(parameter1;parameter2)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="2">**Parameters**

</td><td class="tableblock halign-left valign-top">parameter1: can be any value of any type

</td></tr><tr><td class="tableblock halign-left valign-top">parameter2: can be any value of any type

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Determines if **parameter1** equals with **parameter2**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">1 if the two parameters are equal or 0 if not

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{equal(1; 2)} returns 0

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### notEqual

<div class="sect1" id="bkmrk-signature-%7Bnot-equal"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{not Equal(parameter1; parameter2)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="2">**Parameters**

</td><td class="tableblock halign-left valign-top">parameter1: can be any value of any type

</td></tr><tr><td class="tableblock halign-left valign-top">parameter2: can be any value of any type

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Determines if **parameter1** not equals with **parameter2**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">0 if the two parameters are equal or 1 if not

</td></tr><tr><td class="tableblock halign-left valign-top">**Example calls**

</td><td class="tableblock halign-left valign-top">{not Equal(1; 2)} returns 1

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### greaterThan

<div class="sect1" id="bkmrk-signature-%7Bgreater-t"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{greater Than(parameter1; parameter2)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="2">**Parameters**

</td><td class="tableblock halign-left valign-top">parameter1: can be any value of any type

</td></tr><tr><td class="tableblock halign-left valign-top">parameter2: can be any value of any type

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Determines if **parameter1** greater than **parameter2**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">1 if **parameter1** greater than **parameter2**, 0 if not

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{greaterThan(3; 3)} returns 0

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### greaterThanOrEqual

<div class="sect1" id="bkmrk-signature-%7Bgreaterth"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{greaterThanOrEqual(parameter1; parameter2)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="2">**Parameters**

</td><td class="tableblock halign-left valign-top">parameter1: can be any value of any type

</td></tr><tr><td class="tableblock halign-left valign-top">parameter2: can be any value of any type

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Determines if **parameter1** greater than or equal **parameter2**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">1 if **parameter1** greater than or equal **parameter2**, 0 if not

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{greaterThanOrEqual(3; 3)} returns 1

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### lessThan

<div class="sect1" id="bkmrk-signature-%7Blessthan%28"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{lessThan(parameter1; parameter2)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="2">**Parameters**

</td><td class="tableblock halign-left valign-top">parameter1: can be any value of any type

</td></tr><tr><td class="tableblock halign-left valign-top">parameter2: can be any value of any type

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Determines if **parameter1** less than **parameter2**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">1 if **parameter1** less than **parameter2**, 0 if not

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{lessThan(3; 3)} returns 0

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### lessThanOrEqual

<div class="sect1" id="bkmrk-signature-%7Blessthano"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{lessThanOrEqual(parameter1; parameter2)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="2">**Parameters**

</td><td class="tableblock halign-left valign-top">parameter1: can be any value of any type

</td></tr><tr><td class="tableblock halign-left valign-top">parameter2: can be any value of any type

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Determines if **parameter1** less than or equal **parameter2**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">1 if **parameter1** less than or equal **parameter2**, 0 if not

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{lessThanOrEqual(3; 3)} returns 1

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### empty

<div class="sect1" id="bkmrk-signature-%7Bempty%28par"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{empty(parameter)}

</td></tr><tr><td class="tableblock halign-left valign-top">**Parameters**

</td><td class="tableblock halign-left valign-top">parameter: text value

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Determines if **parameter** is empty

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">1 if **parameter** is empty, 0 if not

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{empty(any text)} returns 0

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### notEmpty

<div class="sect1" id="bkmrk-signature-%7Bnotempty%28"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{notEmpty(parameter)}

</td></tr><tr><td class="tableblock halign-left valign-top">**Parameters**

</td><td class="tableblock halign-left valign-top">parameter: text value

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Determines if **parameter** is not empty

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">1 if **parameter** is not empty, 0 if empty

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{notEmpty(any text)} returns 1

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### not

<div class="sect1" id="bkmrk-signature-%7Bnot%28param"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{not(parameter)}

</td></tr><tr><td class="tableblock halign-left valign-top">**Parameters**

</td><td class="tableblock halign-left valign-top">parameter: logical value

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Negates the logical value of the **parameter**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">1 if **parameter** is 0, 0 if **parameter** is 1

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{not(0)} returns 1

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### and

<div class="sect1" id="bkmrk-signature-%7Band%28param"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{and(parameter1; parameter2)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="2">**Parameters**

</td><td class="tableblock halign-left valign-top">parameter1: logical value

</td></tr><tr><td class="tableblock halign-left valign-top">parameter2: logical value

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Applies the AND logical operator to two logical values

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">1 if **parameter1** and **parameter2** is 1, 0 if any parameters are 0

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{and(1; 0)} returns 0

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### or

<div class="sect1" id="bkmrk-signature-%7Bor%28parame"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{or(parameter1; parameter2)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="2">**Parameters**

</td><td class="tableblock halign-left valign-top">parameter1: logical value

</td></tr><tr><td class="tableblock halign-left valign-top">parameter2: logical value

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Applies the OR logical operator to two logical values

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">1 if **parameter1** or **parameter2** is 1, 0 if both parameters are 0

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{or(1; 0)} returns 1

</td></tr></tbody></table>

</div></div><div class="sect2">  
</div></div></div>### Text Functions

Text functions are used to manipulate text in various ways. All the functions listed here are fully supports UTF-8 texts, so special characters should not raise any problems.

#### substring

<div class="sect1" id="bkmrk-signature-%7Bsubstring"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all stretch"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{substring(text; start; length)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="3">**Parameters**

</td><td class="tableblock halign-left valign-top">text: text value

</td></tr><tr><td class="tableblock halign-left valign-top">start: decimal value

</td></tr><tr><td class="tableblock halign-left valign-top">length \[optional parameter\]: decimal value

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Cuts the substring of a text field from **start**. If the **length** optional parameter is not set, then it cuts all characters until the end of the string, otherwise cuts the provided **length**. Indexing of a text’s characters starting from 0.

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">Substring of the given text

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="2">**Example call**

</td><td class="tableblock halign-left valign-top">{substring(This is my text; 5)} returns is my text

</td></tr><tr><td class="tableblock halign-left valign-top">{substring(This is my text; 5; 5)} returns is my

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### length

<div class="sect1" id="bkmrk-signature-%7Blength%28pa"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{length(parameter)}

</td></tr><tr><td class="tableblock halign-left valign-top">**Parameters**

</td><td class="tableblock halign-left valign-top">parameter: text value

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Count the characters in a text.

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">The count of the characters in a text.

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{length(sample text)} returns 11

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### replace

<div class="sect1" id="bkmrk-signature-%7Breplace%28s"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">Signature

</td><td class="tableblock halign-left valign-top">{replace(search; replace; subject)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="3">Parameters

</td><td class="tableblock halign-left valign-top">search: text value

</td></tr><tr><td class="tableblock halign-left valign-top">replace: text value

</td></tr><tr><td class="tableblock halign-left valign-top">subject: text value

</td></tr><tr><td class="tableblock halign-left valign-top">Description

</td><td class="tableblock halign-left valign-top">Replace all occurrences of **search** to **replace** in the text **subject**.

</td></tr><tr><td class="tableblock halign-left valign-top">Returns

</td><td class="tableblock halign-left valign-top">**subject** with replaced values.

</td></tr><tr><td class="tableblock halign-left valign-top">Example call

</td><td class="tableblock halign-left valign-top">{replace(apple; orange; This is an apple tree)} returns This is an orange tree

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### position

<div class="sect1" id="bkmrk-signature-%7Bposition%28"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{position(subject; search)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="2">**Parameters**

</td><td class="tableblock halign-left valign-top">subject: text value

</td></tr><tr><td class="tableblock halign-left valign-top">search: text value

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Find position of first occurrence of **search** in a **subject**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">Numeric position of **search** in **subject** or -1 if **search** not present in **subject**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{position(Where is my text?; text)} returns 12

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### lowercase

<div class="sect1" id="bkmrk-signature-%7Blowercase"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{lowercase(parameter)}

</td></tr><tr><td class="tableblock halign-left valign-top">**Parameters**

</td><td class="tableblock halign-left valign-top">parameter: text value

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Make text lowercase

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">The lowercased text.

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{lowercase(ThIs iS a sAmPlE tExT)} returns this is a sample text

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### uppercase

<div class="sect1" id="bkmrk-signature-%7Buppercase"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{uppercase(parameter)}

</td></tr><tr><td class="tableblock halign-left valign-top">**Parameters**

</td><td class="tableblock halign-left valign-top">parameter: text value

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Make text uppercase

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">The uppercased text.

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{uppercase(ThIs iS a sAmPlE tExT)} returns THIS IS A SAMPLE TEXT

</td></tr></tbody></table>

</div></div><div class="sect2">  
</div></div></div>### Mathematical Functions

Mathematical functions are used to manipulate numbers in various ways. Several mathematical operators are implemented as functions in Calculate Fields.

#### add

<div class="sect1" id="bkmrk-signature-%7Badd%28param"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{add(parameter1; parameter2)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="2">**Parameters**

</td><td class="tableblock halign-left valign-top">parameter1: number value

</td></tr><tr><td class="tableblock halign-left valign-top">parameter2: number value

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Adds **parameter1** and **parameter2**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">The sum of **parameter1** and **parameter2**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{add(3.12; 4.83)} returns 7.95

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### subtract

<div class="sect1" id="bkmrk-signature-%7Bsubtract%28"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{subtract(parameter1; parameter2)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="2">**Parameters**

</td><td class="tableblock halign-left valign-top">parameter1: number value

</td></tr><tr><td class="tableblock halign-left valign-top">parameter2: number value

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Subtracts **parameter2** from **parameter1**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">The distinction of **parameter2** and **parameter1**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{subtract(8; 3)} returns 5

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### multiply

<div class="sect1" id="bkmrk-signature-%7Bmultiply%28"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{multiply(parameter1; parameter2)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="2">**Parameters**

</td><td class="tableblock halign-left valign-top">parameter1: number value

</td></tr><tr><td class="tableblock halign-left valign-top">parameter2: number value

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Multiplies **parameter1** and **parameter2**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">The product of **parameter1** and **parameter2**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{multiply(2; 4)} returns 8

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### divide

<div class="sect1" id="bkmrk-signature-%7Bdivide%28pa"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{divide(parameter1; parameter2)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="2">**Parameters**

</td><td class="tableblock halign-left valign-top">parameter1: number value

</td></tr><tr><td class="tableblock halign-left valign-top">parameter2: number value

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Divides **parameter2** with **parameter1**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">The division of **parameter2** and **parameter1**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{divide(8; 2)} returns 4

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### power

<div class="sect1" id="bkmrk-signature-%7Bpower%28par"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{power(parameter1; parameter2)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="2">**Parameters**

</td><td class="tableblock halign-left valign-top">parameter1: number value

</td></tr><tr><td class="tableblock halign-left valign-top">parameter2: number value

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Raises **parameter1** to the power of **parameter2**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">**parameter1** raised to the power of **parameter2**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{power(2; 7)} returns 128

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### squareRoot

<div class="sect1" id="bkmrk-signature-%7Bsquareroo"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{squareRoot(parameter)}

</td></tr><tr><td class="tableblock halign-left valign-top">**Parameters**

</td><td class="tableblock halign-left valign-top">parameter: number value

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Calculates the square root of **parameter**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">The square root of **parameter**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{squareRoot(4)} returns 2

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### absolute

<div class="sect1" id="bkmrk-signature-%7Babsolute%28"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{absolute(parameter)}

</td></tr><tr><td class="tableblock halign-left valign-top">**Parameters**

</td><td class="tableblock halign-left valign-top">parameter: number value

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Calculates the absolute value of **parameter**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">The absolute value of **parameter**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{absolute(-4)} returns 4

</td></tr></tbody></table>

</div></div><div class="sect2">  
</div></div></div>### Date functions

There are several date functions implemented in Calculate Fields, so the user can manipulate dates in many ways. Most of the functions uses a format parameter, which is used to set the result of the functions formatted as the user wants to. The options for these formats are equivalent with the PHP format parameters:

<div class="sect1" id="bkmrk-format-character-des"><div class="sectionbody"><div class="sect2"><div class="paragraph">  
</div><table class="tableblock frame-all grid-all stretch"><colgroup><col></col><col></col><col></col></colgroup><thead><tr><th class="tableblock halign-left valign-top">Format character</th><th class="tableblock halign-left valign-top">Description</th><th class="tableblock halign-left valign-top">Example returned values</th></tr></thead><tbody><tr><th class="tableblock halign-left valign-top" colspan="3">**For day**

</th></tr><tr><td class="tableblock halign-left valign-top">d

</td><td class="tableblock halign-left valign-top">Day of the month, 2 digits with leading zeros

</td><td class="tableblock halign-left valign-top">01 to 31

</td></tr><tr><td class="tableblock halign-left valign-top">D

</td><td class="tableblock halign-left valign-top">A textual representation of a day, three letters

</td><td class="tableblock halign-left valign-top">Mon through Sun

</td></tr><tr><td class="tableblock halign-left valign-top">j

</td><td class="tableblock halign-left valign-top">Day of the month without leading zeros

</td><td class="tableblock halign-left valign-top">1 to 31

</td></tr><tr><td class="tableblock halign-left valign-top">l

</td><td class="tableblock halign-left valign-top">A full textual representation of the day of the week

</td><td class="tableblock halign-left valign-top">Sunday through Saturday

</td></tr><tr><td class="tableblock halign-left valign-top">N

</td><td class="tableblock halign-left valign-top">ISO-8601 numeric representation of the day of the week

</td><td class="tableblock halign-left valign-top">1 (for Monday) through 7 (for Sunday)

</td></tr><tr><td class="tableblock halign-left valign-top">S

</td><td class="tableblock halign-left valign-top">English ordinal suffix for the day of the month, 2 characters

</td><td class="tableblock halign-left valign-top">st, nd, rd or th. Works well with j

</td></tr><tr><td class="tableblock halign-left valign-top">w

</td><td class="tableblock halign-left valign-top">Numeric representation of the day of the week

</td><td class="tableblock halign-left valign-top">0 (for Sunday) through 6 (for Saturday)

</td></tr><tr><td class="tableblock halign-left valign-top">z

</td><td class="tableblock halign-left valign-top">The day of the year (starting from 0)

</td><td class="tableblock halign-left valign-top">0 through 365

</td></tr><tr><th class="tableblock halign-left valign-top" colspan="3">**For week**

</th></tr><tr><td class="tableblock halign-left valign-top">W

</td><td class="tableblock halign-left valign-top">ISO-8601 week number of year, weeks starting on Monday

</td><td class="tableblock halign-left valign-top">42 (the 42nd week in the year)

</td></tr><tr><th class="tableblock halign-left valign-top" colspan="3">**For month**

</th></tr><tr><td class="tableblock halign-left valign-top">F

</td><td class="tableblock halign-left valign-top">A full textual representation of a month, such as January or March

</td><td class="tableblock halign-left valign-top">January through December

</td></tr><tr><td class="tableblock halign-left valign-top">m

</td><td class="tableblock halign-left valign-top">Numeric representation of a month, with leading zeros

</td><td class="tableblock halign-left valign-top">01 through 12

</td></tr><tr><td class="tableblock halign-left valign-top">M

</td><td class="tableblock halign-left valign-top">A short textual representation of a month, three letters

</td><td class="tableblock halign-left valign-top">Jan through Dec

</td></tr><tr><td class="tableblock halign-left valign-top">n

</td><td class="tableblock halign-left valign-top">Numeric representation of a month, without leading zeros

</td><td class="tableblock halign-left valign-top">1 through 12

</td></tr><tr><td class="tableblock halign-left valign-top">t

</td><td class="tableblock halign-left valign-top">Number of days in the given month

</td><td class="tableblock halign-left valign-top">28 through 31

</td></tr><tr><th class="tableblock halign-left valign-top" colspan="3">**For year**

</th></tr><tr><td class="tableblock halign-left valign-top">L

</td><td class="tableblock halign-left valign-top">Whether it’s a leap year

</td><td class="tableblock halign-left valign-top">1 if it is a leap year, 0 otherwise

</td></tr><tr><td class="tableblock halign-left valign-top">o

</td><td class="tableblock halign-left valign-top">ISO-8601 year number. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead

</td><td class="tableblock halign-left valign-top">1999 or 2003

</td></tr><tr><td class="tableblock halign-left valign-top">Y

</td><td class="tableblock halign-left valign-top">A full numeric representation of a year, 4 digits

</td><td class="tableblock halign-left valign-top">1999 or 2003

</td></tr><tr><td class="tableblock halign-left valign-top">y

</td><td class="tableblock halign-left valign-top">A two digit representation of a year

</td><td class="tableblock halign-left valign-top">99 or 03

</td></tr><tr><th class="tableblock halign-left valign-top" colspan="3">**For time**

</th></tr><tr><td class="tableblock halign-left valign-top">a

</td><td class="tableblock halign-left valign-top">Lowercase Ante meridiem and Post meridiem

</td><td class="tableblock halign-left valign-top">am or pm

</td></tr><tr><td class="tableblock halign-left valign-top">A

</td><td class="tableblock halign-left valign-top">Uppercase Ante meridiem and Post meridiem

</td><td class="tableblock halign-left valign-top">AM or PM

</td></tr><tr><td class="tableblock halign-left valign-top">B

</td><td class="tableblock halign-left valign-top">Swatch Internet time

</td><td class="tableblock halign-left valign-top">000 through 999

</td></tr><tr><td class="tableblock halign-left valign-top">g

</td><td class="tableblock halign-left valign-top">12-hour format of an hour without leading zeros

</td><td class="tableblock halign-left valign-top">1 through 12

</td></tr><tr><td class="tableblock halign-left valign-top">G

</td><td class="tableblock halign-left valign-top">24-hour format of an hour without leading zeros

</td><td class="tableblock halign-left valign-top">0 through 23

</td></tr><tr><td class="tableblock halign-left valign-top">h

</td><td class="tableblock halign-left valign-top">12-hour format of an hour with leading zeros

</td><td class="tableblock halign-left valign-top">01 through 12

</td></tr><tr><td class="tableblock halign-left valign-top">H

</td><td class="tableblock halign-left valign-top">24-hour format of an hour with leading zeros

</td><td class="tableblock halign-left valign-top">00 through 23

</td></tr><tr><td class="tableblock halign-left valign-top">i

</td><td class="tableblock halign-left valign-top">Minutes with leading zeros

</td><td class="tableblock halign-left valign-top">00 to 59

</td></tr><tr><td class="tableblock halign-left valign-top">s

</td><td class="tableblock halign-left valign-top">Seconds, with leading zeros

</td><td class="tableblock halign-left valign-top">00 through 59

</td></tr><tr><th class="tableblock halign-left valign-top" colspan="3">**For timezone**

</th></tr><tr><td class="tableblock halign-left valign-top">e

</td><td class="tableblock halign-left valign-top">Timezone identifier

</td><td class="tableblock halign-left valign-top">UTC, GMT, Atlantic/Azores

</td></tr><tr><td class="tableblock halign-left valign-top">l

</td><td class="tableblock halign-left valign-top">Whether or not the date is in daylight saving time

</td><td class="tableblock halign-left valign-top">1 if Daylight Saving Time, 0 otherwise

</td></tr><tr><td class="tableblock halign-left valign-top">O

</td><td class="tableblock halign-left valign-top">Difference to Greenwich time (GMT) in hours

</td><td class="tableblock halign-left valign-top">+0200

</td></tr><tr><td class="tableblock halign-left valign-top">P

</td><td class="tableblock halign-left valign-top">Difference to Greenwich time (GMT) with colon between hours and minutes

</td><td class="tableblock halign-left valign-top">+02:00

</td></tr><tr><td class="tableblock halign-left valign-top">T

</td><td class="tableblock halign-left valign-top">Timezone abbreviation

</td><td class="tableblock halign-left valign-top">EST, MDT

</td></tr><tr><td class="tableblock halign-left valign-top">Z

</td><td class="tableblock halign-left valign-top">Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive.

</td><td class="tableblock halign-left valign-top">-43200 through 50400

</td></tr><tr><th class="tableblock halign-left valign-top" colspan="3">**For full date/time**

</th></tr><tr><td class="tableblock halign-left valign-top">c

</td><td class="tableblock halign-left valign-top">ISO 8601 date

</td><td class="tableblock halign-left valign-top">2004-02-12T15:19:21+00:00

</td></tr><tr><td class="tableblock halign-left valign-top">r

</td><td class="tableblock halign-left valign-top">RFC 2822 formatted date

</td><td class="tableblock halign-left valign-top">Thu, 21 Dec 2000 16:01:07 +0200

</td></tr><tr><td class="tableblock halign-left valign-top">U

</td><td class="tableblock halign-left valign-top">Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)

</td><td class="tableblock halign-left valign-top"> </td></tr></tbody></table>

<div class="paragraph"><div class="notices note"><div class="paragraph">  
</div></div></div></div></div></div>For all functions without timestamp parameter, we assume that the current date/time is 2016.04.29. 15:08:03

#### date

<div class="sect1" id="bkmrk-signature-%7Bdate%28form"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{date(format; timestamp)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="2">**Parameters**

</td><td class="tableblock halign-left valign-top">format: format text

</td></tr><tr><td class="tableblock halign-left valign-top">timestamp: date/time value

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Creates a date in the given format

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">**timestamp** in the given **format**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{date(ymd; 2016-02-11)} returns 160211

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### now

<div class="sect1" id="bkmrk-signature-%7Bnow%28forma"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{now(format)}

</td></tr><tr><td class="tableblock halign-left valign-top">**Parameters**

</td><td class="tableblock halign-left valign-top">format: format text

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Creates the actual date/time in the given format

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">Current date/time in the given **format**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{now(Y-m-d H:i:s)} returns 2016-04-29 15:08:03

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### yesterday

<div class="sect1" id="bkmrk-signature-%7Byesterday"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{yesterday(format)}

</td></tr><tr><td class="tableblock halign-left valign-top">**Parameters**

</td><td class="tableblock halign-left valign-top">format: format text

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Creates yesterday’s date/time in the given format

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">Yesterday’s date/time in the given **format**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{yesterday(Y-m-d H:i:s)} returns 2016-04-28 15:08:03

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### tomorrow

<div class="sect1" id="bkmrk-signature-%7Btomorrow%28"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{tomorrow(format)}

</td></tr><tr><td class="tableblock halign-left valign-top">**Parameters**

</td><td class="tableblock halign-left valign-top">format: format text

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Creates tomorrow’s date/time in the given format

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">Tomorrow’s date/time in the given **format**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{tomorrow(Y-m-d H:i:s)} returns 2016-04-30 15:08:03

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### datediff

<div class="sect1" id="bkmrk-signature-%7Bdatediff%28"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{datediff(timestamp1; timestamp2; unit)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="3">**Parameters**

</td><td class="tableblock halign-left valign-top">timestamp1: date/time value

</td></tr><tr><td class="tableblock halign-left valign-top">timestamp2: date/time value

</td></tr><tr><td class="tableblock halign-left valign-top">unit: years/months/days/hours/minutes/seconds; default: days

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Subtracts **timestamp2** from **timestamp1**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">The difference between the two dates returned in **unit**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{datediff(2016-02-01; 2016-04-22; days)} returns 81

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### addYears

<div class="sect1" id="bkmrk-signature-%7Baddyears%28"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{addYears(format; timestamp; amount)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="3">**Parameters**

</td><td class="tableblock halign-left valign-top">format: format text

</td></tr><tr><td class="tableblock halign-left valign-top">timestamp: date/time value

</td></tr><tr><td class="tableblock halign-left valign-top">amount: decimal number

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Adds **amount** years to **timestamp**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">Incremented date in **format**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{addYears(Ymd; 2016-04-22; 1)} returns 20170422

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### addMonths

<div class="sect1" id="bkmrk-signature-%7Baddmonths"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{addMonths(format; timestamp; amount)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="3">**Parameters**

</td><td class="tableblock halign-left valign-top">format: format text

</td></tr><tr><td class="tableblock halign-left valign-top">timestamp: date/time value

</td></tr><tr><td class="tableblock halign-left valign-top">amount: decimal number

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Adds **amount** months to **timestamp**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">Incremented date in **format**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{addMonths(Ymd; 2016-04-22; 1)} returns 20160522

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### addDays

<div class="sect1" id="bkmrk-signature-%7Badddays%28f"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{addDays(format; timestamp; amount)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="3">**Parameters**

</td><td class="tableblock halign-left valign-top">format: format text

</td></tr><tr><td class="tableblock halign-left valign-top">timestamp: date/time value

</td></tr><tr><td class="tableblock halign-left valign-top">amount: decimal number

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Adds **amount** days to **timestamp**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">Incremented date in **format**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{addDays(Ymd; 2016-04-22; 1)} returns 20160423

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### addHours

<div class="sect1" id="bkmrk-signature-%7Baddhours%28"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{addHours(format; timestamp; amount)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="3">**Parameters**

</td><td class="tableblock halign-left valign-top">format: format text

</td></tr><tr><td class="tableblock halign-left valign-top">timestamp: date/time value

</td></tr><tr><td class="tableblock halign-left valign-top">amount: decimal number

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Adds **amount** hours to **timestamp**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">Incremented date in **format**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{addHours(Ymd H:i:s; 2016-04-22 23:30; 5)} returns 20160423 04:30:00

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### addMinutes

<div class="sect1" id="bkmrk-signature-%7Baddminute"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{addMinutes(format; timestamp; amount)}

</td></tr><tr><td class="tableblock halign-left valign-top">**Parameters**

</td><td class="tableblock halign-left valign-top">format: format text

</td></tr><tr><td class="tableblock halign-left valign-top">timestamp: date/time value

</td><td class="tableblock halign-left valign-top">amount: decimal number

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Adds **amount** minutes to **timestamp**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">Incremented date in **format**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{addMinutes(Ymd H:i:s; 2016-04-22 22:58; 5)} returns 20160422 23:03:00

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### addSeconds

<div class="sect1" id="bkmrk-signature-%7Baddsecond"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{addSeconds(format; timestamp; amount)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="3">**Parameters**

</td><td class="tableblock halign-left valign-top">format: format text

</td></tr><tr><td class="tableblock halign-left valign-top">timestamp: date/time value

</td></tr><tr><td class="tableblock halign-left valign-top">amount: decimal number

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Adds **amount** seconds to **timestamp**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">Incremented date in **format**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{addSeconds(Ymd H:i:s; 2016-04-22 22:58; 5)} returns 20160422 22:58:05

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### subtractYears

<div class="sect1" id="bkmrk-signature-%7Bsubtracty"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{subtractYears(format; timestamp; amount)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="3">**Parameters**

</td><td class="tableblock halign-left valign-top">format: format text

</td></tr><tr><td class="tableblock halign-left valign-top">timestamp: date/time value

</td></tr><tr><td class="tableblock halign-left valign-top">amount: decimal number

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Subtracts **amount** years from **timestamp**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">Decremented date in **format**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{subtractYears(Ymd; 2016-04-22; 5)} returns 20110422

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### subtractMonths

<div class="sect1" id="bkmrk-signature-%7Bsubtractm"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{subtractMonths(format; timestamp; amount)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="3">**Parameters**

</td><td class="tableblock halign-left valign-top">format: format text

</td></tr><tr><td class="tableblock halign-left valign-top">timestamp: date/time value

</td></tr><tr><td class="tableblock halign-left valign-top">amount: decimal number

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Subtracts **amount** months from **timestamp**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">Decremented date in **format**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{subtractMonths(Ymd; 2016-04-22; 5)} returns 20151122

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### subtractDays

<div class="sect1" id="bkmrk-signature-%7Bsubtractd"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">Signature

</td><td class="tableblock halign-left valign-top">{subtractDays(format; timestamp; amount)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="3">Parameters

</td><td class="tableblock halign-left valign-top">format: format text

</td></tr><tr><td class="tableblock halign-left valign-top">timestamp: date/time value

</td></tr><tr><td class="tableblock halign-left valign-top">amount: decimal number

</td></tr><tr><td class="tableblock halign-left valign-top">Description

</td><td class="tableblock halign-left valign-top">Subtracts **amount** days from **timestamp**

</td></tr><tr><td class="tableblock halign-left valign-top">Returns

</td><td class="tableblock halign-left valign-top">Decremented date in **format**

</td></tr><tr><td class="tableblock halign-left valign-top">Example call

</td><td class="tableblock halign-left valign-top">{subtractDays(Ymd; 2016-04-22; 5)} returns 20160417

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### subtractHours

<div class="sect1" id="bkmrk-signature-%7Bsubtracth"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{subtractHours(format; timestamp; amount)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="3">**Parameters**

</td><td class="tableblock halign-left valign-top">format: format text

</td></tr><tr><td class="tableblock halign-left valign-top">timestamp: date/time value

</td></tr><tr><td class="tableblock halign-left valign-top">amount: decimal number

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Subtracts **mount** hours from **timestamp**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">Decremented date in **format**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{subtractHours(Ymd H:i:s; 2016-04-22 12:37; 5)} returns 20160422 07:37:00

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### subtractMinutes

<div class="sect1" id="bkmrk-signature-%7Bsubtractm-1"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{subtractMinutes(format; timestamp; amount)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="3">**Parameters**

</td><td class="tableblock halign-left valign-top">format: format text

</td></tr><tr><td class="tableblock halign-left valign-top">timestamp: date/time value

</td></tr><tr><td class="tableblock halign-left valign-top">amount: decimal number

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Subtracts **amount** minutes from **timestamp**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">Decremented date in **format**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{subtractMinutes(Ymd H:i:s; 2016-04-22 12:37; 5)} returns 20160422 12:32:00

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### subtractSeconds

<div class="sect1" id="bkmrk-signature-%7Bsubtracts"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{subtractSeconds(format; timestamp; amount)}

</td></tr><tr><td class="tableblock halign-left valign-top">**Parameters**

</td><td class="tableblock halign-left valign-top">format: format text

</td></tr><tr><td class="tableblock halign-left valign-top">timestamp: date/time value

</td><td class="tableblock halign-left valign-top">amount: decimal number

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Subtracts **amount** minutes from **timestamp**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">Decremented date in **format**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{subtractSeconds(Ymd H:i:s; 2016-04-22 12:37; 5)} returns 20160422 12:36:55

</td></tr></tbody></table>

</div></div><div class="sect2">  
</div></div></div>### Control Functions

There is only one control function implemented in Calculate Fields so far, but this function ensures that the user can write very complex formulas with conditions. Since the functions can be embedded in each other, the user can write junctions with many branches.

#### ifThenElse

<div class="sect1" id="bkmrk-signature-%7Bifthenels"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{ifThenElse(condition; trueBranch; falseBranch)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="3">**Parameters**

</td><td class="tableblock halign-left valign-top">condition: logical value

</td></tr><tr><td class="tableblock halign-left valign-top">trueBranch: any expression

</td></tr><tr><td class="tableblock halign-left valign-top">falseBranch: any expression

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Selects one of the two branches depending on **condition**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">**trueBranch** if **condition** is true, **falseBranch** otherwise

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{ifThenElse(\\{equal(1; 1)}; 1 equals 1; 1 not equals 1)} returns 1 equals 1

</td></tr></tbody></table>

</div></div><div class="sect2">  
</div></div></div>### Counters

There are several counters implemented in Calculate Fields which can be used in various scenarios.

The counters sorted into two groups:

<div class="sect1" id="bkmrk-global-counters%3A%C2%A0cou"><div class="sectionbody"><div class="sect2"><div class="paragraph">  
</div><div class="olist arabic">1. **Global counters:** Counters which are incremented every time an affected formula is evaluated
2. **Daily counters:** Counters which resets every day. (Starting from 1)

</div><div class="paragraph">  
</div></div></div></div>In this chapter we assume that the counters current value is 4, so the incremented value will be 5 with the given format.

#### GlobalCounter

<div class="sect1" id="bkmrk-signature-%7Bglobalcou"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{GlobalCounter(name; numberLength)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="2">**Parameters**

</td><td class="tableblock halign-left valign-top">name: any text

</td></tr><tr><td class="tableblock halign-left valign-top">numberLength: decimal number

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Increments and returns the counter for **name** with length **numberLength**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">Counter with length **numberLength**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{GlobalCounter(myName; 4)} returns 0005

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### GlobalCounterPerUser

<div class="sect1" id="bkmrk-signature-%7Bglobalcou-1"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{GlobalCounterPerUser(name; numberLength)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="2">**Parameters**

</td><td class="tableblock halign-left valign-top">name: any text

</td></tr><tr><td class="tableblock halign-left valign-top">numberLength: decimal number

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Increments and returns the counter for **name** for the user who creates the entity with length **numberLength**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">Counter with length **numberLength**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{GlobalCounterPerUser(myName; 3)} returns 005

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### GlobalCounterPerModule

<div class="sect1" id="bkmrk-signature-%7Bglobalcou-2"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{GlobalCounterPerModule(name; numberLength)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="2">**Parameters**

</td><td class="tableblock halign-left valign-top">name: any text

</td></tr><tr><td class="tableblock halign-left valign-top">numberLength: decimal number

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Increments and returns the counter for **name** for the module of the entity with length **numberLength**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">Counter with length **numberLength**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{GlobalCounterPerModule(myName; 2)} returns 05

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### GlobalCounterPerUserPerModule

<div class="sect1" id="bkmrk-signature-%7Bglobalcou-3"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{GlobalCounterPerUserPerModule(name; numberLength)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="2">**Parameters**

</td><td class="tableblock halign-left valign-top">name: any text

</td></tr><tr><td class="tableblock halign-left valign-top">numberLength: decimal number

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Increments and returns the counter for **name** for the user who creates the entity and for the module of the entity with length **numberLength**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">Counter with length **numberLength**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{GlobalCounterPerUserPerModule(myName; 1)} returns 5

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### DailyCounter

<div class="sect1" id="bkmrk-signature-%7Bdailycoun"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{DailyCounter(name; numberLength)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="2">**Parameters**

</td><td class="tableblock halign-left valign-top">name: any text

</td></tr><tr><td class="tableblock halign-left valign-top">numberLength: decimal number

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Increments and returns the counter for **name** with length **numberLength**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">Counter with length **numberLength**, or if the counter is not incremented this day then 1 with length **numberLength**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{DailyCounter(myName; 1)} returns 5

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### DailyCounterPerUser

<div class="sect1" id="bkmrk-signature-%7Bdailycoun-1"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{DailyCounterPerUser(name; numberLength)}

</td></tr><tr><td class="tableblock halign-left valign-top">**Parameters**

</td><td class="tableblock halign-left valign-top">name: any text

</td></tr><tr><td class="tableblock halign-left valign-top">numberLength: decimal number

</td><td class="tableblock halign-left valign-top">**Description**

</td></tr><tr><td class="tableblock halign-left valign-top">Increments and returns the counter for **name** for the user who creates the entity with length **numberLength**

</td><td class="tableblock halign-left valign-top">**Returns**

</td></tr><tr><td class="tableblock halign-left valign-top">Counter with length **numberLength**, or if the counter is not incremented this day for this user then 1 with length **numberLength**

</td><td class="tableblock halign-left valign-top">**Example call**

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### DailyCounterPerModule

<div class="sect1" id="bkmrk-signature-%7Bdailycoun-2"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Signature**

</td><td class="tableblock halign-left valign-top">{DailyCounterPerModule(name; numberLength)}

</td></tr><tr><td class="tableblock halign-left valign-top" rowspan="2">**Parameters**

</td><td class="tableblock halign-left valign-top">name: any text

</td></tr><tr><td class="tableblock halign-left valign-top">numberLength: decimal number

</td></tr><tr><td class="tableblock halign-left valign-top">**Description**

</td><td class="tableblock halign-left valign-top">Increments and returns the counter for **name** for the module of the entity with length **numberLength**

</td></tr><tr><td class="tableblock halign-left valign-top">**Returns**

</td><td class="tableblock halign-left valign-top">Counter with length **numberLength**, or if the counter is not incremented this day for this module then 1 with length **numberLength**

</td></tr><tr><td class="tableblock halign-left valign-top">**Example call**

</td><td class="tableblock halign-left valign-top">{DailyCounterPerModule(myName; 1)} returns 5

</td></tr></tbody></table>

</div><div class="sect3">  
</div></div></div></div>#### DailyCounterPerModule

<div class="sect1" id="bkmrk-signature-%7Bdailycoun-3"><div class="sectionbody"><div class="sect2"><div class="sect3"><table class="tableblock frame-all grid-all" style="width: 100%; height: 244.8px;"><colgroup><col style="width: 9.28571%;"></col><col style="width: 90.5952%;"></col></colgroup><tbody><tr style="height: 46.4px;"><td class="tableblock halign-left valign-top" style="height: 46.4px;">**Signature**

</td><td class="tableblock halign-left valign-top" style="height: 46.4px;">{DailyCounterPerUserPerModule(name; numberLength)}

</td></tr><tr style="height: 29.6px;"><td class="tableblock halign-left valign-top" rowspan="2" style="height: 59.2px;">**Parameters**

</td><td class="tableblock halign-left valign-top" style="height: 29.6px;">name: any text

</td></tr><tr style="height: 29.6px;"><td class="tableblock halign-left valign-top" style="height: 29.6px;">numberLength: decimal number

</td></tr><tr style="height: 46.4px;"><td class="tableblock halign-left valign-top" style="height: 46.4px;">**Description**

</td><td class="tableblock halign-left valign-top" style="height: 46.4px;">Increments and returns the counter for **name** for the user who creates the entity and for the module of the entity with length **numberLength**

</td></tr><tr style="height: 46.4px;"><td class="tableblock halign-left valign-top" style="height: 46.4px;">**Returns**

</td><td class="tableblock halign-left valign-top" style="height: 46.4px;">Counter with length **numberLength**, or if the counter is not incremented this day for the user who creates the entity and for this module then 1 with length **numberLength**

</td></tr><tr style="height: 46.4px;"><td class="tableblock halign-left valign-top" style="height: 46.4px;">**Example call**

</td><td class="tableblock halign-left valign-top" style="height: 46.4px;">{DailyCounterPerUserPerModule(myName; 1)} returns 5

</td></tr></tbody></table>

</div></div><div class="sect2">  
</div></div></div>### Example - Calculate monthly fee for an Opportunity

#### Use Case

The user would like to calculate a monthly fee of an opportunity to a custom field by dividing the amount of the opportunity by the duration.

#### Setup

Our opportunities module has a dropdown field called Duration with values: (database value in brackets) 6 months \[6\], 1 year \[12\], 2 years \[24\]. There is also a currency field called Monthly.

#### Workflow

Go to Workflow module and create a new Workflow. Set the base options like the following:

<div class="sect1" id="bkmrk-name%3A%C2%A0as-you-wish-wo"><div class="sectionbody"><div class="sect2"><div class="sect3"><div class="paragraph">  
</div><table class="tableblock frame-all grid-all"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="tableblock halign-left valign-top">**Name:** as you wish

</td><td class="tableblock halign-left valign-top">**Workflow Module:** Opportunities

</td></tr><tr><td class="tableblock halign-left valign-top">**Status:** Active

</td><td class="tableblock halign-left valign-top">**Run:** Only on save

</td></tr><tr><td class="tableblock halign-left valign-top">**Run on:** All records

</td><td class="tableblock halign-left valign-top">**Repeated runs:** checked

</td></tr></tbody></table>

<div class="paragraph">  
</div></div></div></div></div>[![image.png](https://docs.kiyocrm.com/uploads/images/gallery/2025-05/scaled-1680-/Rjpimage.png)](https://docs.kiyocrm.com/uploads/images/gallery/2025-05/Rjpimage.png)

We do not create any conditions, since we would like the Workflow to run on all opportunities.

Now, add an action and select Calculate Fields from the dropdown.

Then, add two fields from Opportunities as parameters. First, select Opportunity amount (amount) and add it as a parameter (it will be {P0}) then select Duration and the raw value option from the data type dropdown and add it as parameter two (it will be {P1}). There is no need to add any relational parameters for this formula.

Now, add a formula for the monthly field and fill the textbox with the following formula:

<div class="sect1" id="bkmrk--10"><div class="sectionbody"><div class="sect2"><div class="sect3"><div class="paragraph">  
</div><div class="literalblock"><div class="content">  
</div></div></div></div></div></div>```
{divide({P0}; {P1})}
```

<div class="sect1" id="bkmrk--11"><div class="sectionbody"><div class="sect2"><div class="sect3"><div class="literalblock"><div class="content">  
</div></div><div class="paragraph">  
</div></div></div></div></div>So the whole action should look like this:

<span class="image">[![ExampleCF updated1](https://docs.suitecrm.com/images/en/user/ExampleCF_updated1.png "Example Workflow")](https://docs.suitecrm.com/images/en/user/ExampleCF_updated1.png)</span>

Save the Workflow and create a new Opportunity:

<span class="image">[![ExampleCF orig2](https://docs.suitecrm.com/images/en/user/ExampleCF_orig2.png "Example Workflow")](https://docs.suitecrm.com/images/en/user/ExampleCF_orig2.png)</span>

As you can see, we did not even add the monthly field to the EditView, because we don’t want to force the user to make calculations. Save the Opportunity and check the results on the DetailView:

<span class="image">[![ExampleCF orig3](https://docs.suitecrm.com/images/en/user/ExampleCF_orig3.png "Example Workflow")](https://docs.suitecrm.com/images/en/user/ExampleCF_orig3.png)</span>

AOW Calculated Fields was contributed by [diligent technology &amp; business consulting GmbH](http://www.dtbc.eu/)

#### Removing Actions

You can remove Action Lines by clicking the '**X**' on the top right-hand side of the Action.

[![image.png](https://docs.kiyocrm.com/uploads/images/gallery/2025-05/scaled-1680-/Gb5image.png)](https://docs.kiyocrm.com/uploads/images/gallery/2025-05/Gb5image.png)

#### Removing Fields and Relationship Lines

You can remove Field and Relationship Lines by clicking the '**-**' on the left-hand side of the Action.

[![image.png](https://docs.kiyocrm.com/uploads/images/gallery/2025-05/scaled-1680-/Ay8image.png)](https://docs.kiyocrm.com/uploads/images/gallery/2025-05/Ay8image.png)