Login    Sites MenuBlueStep

BlueStep Platform Support

RelateScript
Outline full outline 
Overview 
Data Types 
Operators 
Order of Operations 
Assignment 
String Concatenation 
Arithmetic & Date/Time Operators 
Comparative Operators 
Logical Operators 
Casting Operators 
Increment and Decrement Operators 
The Conditional Operator 
Bitwise Operators 
Statements 
Functions 
Working with Relate Data 
How Formulas Work 
Related Topics 

The arithmetic operators do simple mathematical operations that are familiar to most individuals. They work with numbers (Integer and Float) and are also used to do date math. For all of the arithmetic operators, if one of the input values is null the result will be null.

Addition: +
Addition works with Integer and Float values in the normal way you would expect. If both inputs are Integers then the result is an Integer, otherwise the result is a Float.

Addition also works with DateDiff values added to other DateDiff values, to Date values, to Time values and to DateTime values. If a DateDiff is added to a Date, the result is a Date. If a DateDiff is added to a Time, the result is a Time. For a DateTime, same rule applies. The result is a DateDiff only when a DateDiff is added to another DateDiff. The operands can be in either order and the result is the same. In other words, addition is commutative when doing date and time math.

Subtraction: -
Subtraction works with Integer and Float values in the normal way you would expect.  If both inputs are Integers then the result is an Integer, otherwise the result is a Float.

Subtraction also works with DateDiff values subtracted from other DateDiff values, from Date values, from Time values and from DateTime values. If a DateDiff is subtracted from a Date, the result is a Date. If a DateDiff is subtracted from a Time, the result is a Time. For a DateTime, same rule applies. The result is a DateDiff only when a DateDiff is subtracted from another DateDiff. The DateDiff value must be the second operand; in other words, you cannot subtract a Date from a DateDiff, even though you can subtract a DateDiff from a Date.

Finally, subtraction works with two Time values, two Date values or two DateTime values with the result being a DateDiff. This is where the term DateDiff comes from originally. You can subtract in either order, but the results will be different: one result will be the negative of the other.

Negation: -
Negation receives only one input, such as: -x.  It works with Integer, Float and DateDiff values. The result is the negative of the original and is of the same data type.

Multiplication: *
Multiplication works with Integer and Float values in the normal way you would expect. If both inputs are Integers, then the result is an Integer, otherwise the result is a Float.

Multiplication also works with DateDiff values multiplied by Integer values or by Float values. The result is always a DateDiff. The operands can be in either order and the result is the same. In other words, multiplication is commutative when doing DateDiff math.

Division: /
Division works with Integer and Float values in the normal way you would expect. If both inputs are Integers, then the result is an Integer and the remainder is discarded, otherwise the result is a Float.

Division also works with DateDiff values divided by Integer values or by Float values. The result is always a DateDiff. The DateDiff value must be the first operand, in otherwords, you cannot divide an Integer by a DateDiff even though you can divide a DateDiff by an Integer.

Mod (Remainder): %
Mod works with Integer and Float values and returns the remainder after doing a division. If both inputs are Integers then the result is an Integer; otherwise the result is a Float. For example 5 divided by 3 is 1, remainder 2; so 5 % 3 is 2. For Float the logic is the same, but it is more complex to think about. For example 7.8 divided by 1.5 is 5, remainder 0.3; so 7.8 % 1.5 is 0.3.