Addition operation
Learn how to add two numeric or temporal values together.
The addition operation adds two operands together, either numeric or temporal values, and returns the sum.
To use the addition operation, place a + sign between two numeric values:
/*<operand>*/ + /*<operand>*/
Alternatively, for a more natural language feel, you can write it as follows:
/*<operand>*/ plus /*<operand>*/
Here is a practical example:
5 + 3 // 8
For temporal values, the addition operation allows you to perform calculations involving dates, times, and durations:
today + 1 day
The example above adds one day to the current date, resulting in the date of tomorrow. And you can also chain multiple operations together to perform more complex calculations:
today + 1 month + 1 week
Because the addition operation is commutative, the order of the operands does not matter. This is confirmed by the expression below:
1 day + today is equal to today + 1 day
Note that the addition operation does not automatically convert temporal values. Be sure to use the cast modifier to convert a value to a date or time before adding it to another value, as shown below:
"2021-01-01" as date + 1 day