Examples
Some example of calculation expressions are as under
No of days to today
today() - ${start_start}
Sum of three numbers
${number1} + ${number2} + ${number3}
Average of three numbers
(${number1} + ${number2} + ${number3}) div 3
First 3 characters of a string
substr(${string}, 0, 3)
Length of a string
string-length(${string})
Weighted average of two numbers
(${number1}*${weight1} + ${number2}*${weight2}) div (${weight1} + ${weight2})
Add 30 days to a given date
date(${my_date} + 30)
Maximum of two numbers
max(${number1}, ${number2})
Get string 'Even' or 'Odd' of a number
if(${number} mod 2 = 0, 'Even', 'Odd')
Calculate age from date of birth
int((today() - ${dob}) div 365.25)
Nested if
if(${number} < 5, 'Less than 5', if(${number} >= 5 and ${number} <= 10, 'Between 5 and 10', if(${number} > 10 and ${number} < 25, 'Greater than 10 and less than 25', 'Greater than 25')))
Check if date is Saturday or Sunday
if(format-date(${my_date}, '%a') = 'Sat' or format-date(${my_date}, '%a') = 'Sun', 'Weekend', 'Weekday')
Leap year
if(${my_year} mod 400 = 0 or (${my_year} mod 4 = 0 and ${my_year} mod 100 != 0), 'Leap Year', 'Not a Leap Year')
Last updated