ADD
The ADD
function performs addition on two nullable values of a given data type. The function supports the following data types shown in the syntax below:
Syntax
byte? ADD(byte? a, byte? b)
short? ADD(short? a, short? b)
int? ADD(int? a, int? b)
long? ADD(long? a, long? b)
Single? ADD(Single? a, Single? b)
double? ADD(double? a, double? b)
double? ADD(double? a, decimal? b)
decimal? ADD(decimal? a, double? b)
decimal? ADD(decimal? a, decimal? b)
Example
You can choose to calculate using specific numbers or you can intersperse column data into the function.
For example, you can add two integers with a function such as:
ADD(1000, 2000)
This would return 3000
To add decimals:
ADD(1.23, 4.56)
This would return 5.79
To use the data contained within your columns on a row by row basis you can add the column names into the function.
For example you might have employee holiday allowances to calculate. If the column containing the amount of holiday an employee has was labelled HolidayAllowance and the number of days current taken was HolidayTaken (where holiday taken is a negative number e.g. -15) then the function would be:
ADD(HolidayAllowance, HolidayTaken)
If you wanted to work out how much holiday allowance an employee has when the company has a policy that gives an extra 5 days holiday if they are employed for 5 years, then you can combine other functions within the ADD function:
ADD(BasicHolidayAllowance, IF(DATEDIFF("year", StartDate, TODAY())>=5, 5, 0)
This will add 5 days to the BasicHolidayAllowance value if the difference between the employee StartDate and today's date is equal to or greater than 5 years, otherwise it will add 0.