Appendix 2: Formula Operators
The formula operators Logi JReport provides can be divided into the following four types: Math, Comparison, Boolean and Others.
Math
Operator | Description | Example |
---|---|---|
date x + integer y | When a Date value is added to an Integer value, the return value will be a Date value because the Integer value will have changed to a Date value. | If the date is Oct. 15, 1999, the return value of the following statement is 10-25-99.
|
datetime x + integer y | When a DateTime value is added to an Integer value, the return value will be a DateTime value because the Integer value will have changed to a DateTime value. | If the datetime is Aug. 10, 1999 10:21:30, the return value of the following statement is 1999-08-10 10:21:40.
|
numeric x + y | Adds x and y, and numeric adds to numeric. The returning value's precision will correspond to the data type with the higher precision except when a BigInt value is added to a real number. In this case, the return value will be a BigDecimal.
Note: Each data type has its own precision. For the Integer type data, BigInt has the highest precision while integer has the lowest precision. For the real number type data, Currency has the highest precision while Float has the lowest precision. So, if two numeric data fields of different precision are added together, the return value will be the data type with the higher precision. For example, if an Integer is added to a Double, the return value will be a Double value. | The return value of the following expression is 81.71.
|
string x + boolean y | When a String is added to a Boolean value, the return value will be a String because the Boolean value can be changed to a String value, while the String value cannot be changed to a Boolean value. | The return value of the following statement is It is false.
|
string x + currency y | When a String is added to a Currency value, the return value will be a String because the Currency value can be changed to a String value, while the String value cannot be changed to a Currency value. | The return value of the following statement is I spent9.56.
|
string x + date y | When a String is added to a Date value, the return value will be a String because the Date value can be changed to a String value, while the String value cannot be changed to a Date value. | The return value of the following statement is It is 1999-10-15.
|
string x + datetime y | When a String is added to a DateTime value, the return value will be a String because the DateTime value can be changed to a String value, while the String value cannot be changed to a Date value. | The return value of the following statement is It is 1999-10-15 09:37:15.
|
string x + integer y | When a String is added to an Integer value, the return value will be a String because the Integer value can be changed to a String value, while the String value cannot be changed to an Integer value. | The return value of the following statement is The result is9.
|
string x + number y | When a String is added to a Number value, the return value will be a String because the Number value can be changed to a String value, while the String value cannot be changed to a Number value. | The return value of the following statement is The result is9.56.
|
string x + string y | The return value is a String. |
|
string x + text y | When a String is added to a Text value, the return value will be a String because the Text value can be changed to a String value, while the String value cannot be changed to a Text value. | The return value of the following statement is It is 07-Jul-99 7:12:21 AM.
|
string x + time y | When a String is added to a Time value, the return value will be a String because the Time value can be changed to a String value, while the String value cannot be changed to a Time value. | The return value of the following statement is It is 10:10:10.
|
text x + boolean y | When a text value is added to a Boolean value, the return value will be a text value because the Boolean value can be changed to a text value, while the text value cannot be changed to a Boolean value. | The return value of the following statement is falsefalse.
|
text x + currency y | When a text value is added to a Currency value, the return value will be a text value because the Currency value can be changed to a text value, while the text value cannot be changed to a Currency value. Note that with this option, when a Currency value is changed to a text value, the symbol $ is not added. | The return value of the following statement is false10.56.
|
text x + date y | When a text value is added to a Date value, the return value will be a text value because the Date value can be changed to a text value, while the text value cannot be changed to a Date value. | If the date is Aug.10, 1999 and the time is 10:21:30, the return value of the following statement is 10:21:301999-08-10.
|
text x + datetime y | When a text value is added to a DateTime value, the return value will be a text value because the DateTime value can be changed to a text value while the text value cannot be changed to a DateTime value. | If the date is Aug.10, 1999 and the time is 10:21:30, the return value of the following statement is false1999-08-10 10:21:30.
|
text x + integer y | When a text value is added to an Integer value, the return value will be a text value because the Integer value can be changed to a text value, while the text value cannot be changed to an Integer value. | The return value of the following statement is false10.
|
text x + number y | When a text value is added to a Number value, the return value will be a text value because the Number value can be changed to a text value, while the text value cannot be changed to a Number value. | The return value of the following statement is false10.56.
|
text x + string y | The return value is a String. | The return value of the following statement is 25.60is a number.
|
text x + text y | The return value is a text value. | The return value of the following statement is 25.6and6.52.
|
text x + time y | When a text value is added to a Date value, the return value will be a text value because the Date value can be changed to a text value, while the text value cannot be changed to a Date value. | If the date is Aug.10, 1999 and the time is 10:21:30, the return value of the following statement is 99-08-1010:21:30.
|
time x + integer y | When a Time value is added to an Integer value, the return value will be a Time value because the Integer value will have changed to a Time value. | If the time is 10:15:25, the return value of the following statement is 10:15:35.
|
date x - date y | When a Date value is subtracted from a Date value, the return value will be an Integer. The result is the number of days between the two dates. |
|
date x - integer y | When a Integer value is subtracted from an Date value, the return value will be a Date value because the Integer value will have changed into a Date value. | If the date is Oct. 18, 1999, the return value of the following statement is 10/16/99.
|
datetime x - datetime y | When a DateTime value is subtracted from a DateTime value, the return value will be an Integer. The result is the number of seconds between the two DateTimes. | If one date time is 1999-12-12 10:10:10, and the other date time is 1995-12-12 10:10:10, the return value of the following statement is 126230400.
|
datetime x - integer y | When an Integer value is subtracted from a DateTime value, the return value will be a DateTime value because the Integer value will have changed into a DateTime value. | If the date is Oct. 18, 1999, the time is 10:10:10, the return value of the following statement is 1999-10-18 10:10:08.
|
numeric x - numeric y | Subtracts y from x. When a numeric is subtracted from a numeric. The precision of the return value will correspond to the data type with the higher precision.
Note: Each data type has its own precision. For the Integer type data, BigInt has the highest precision while integer has the lowest precision. For the real number type data, Currency has the highest precision while float has the lowest precision. So, if two numeric datum of different precision are subtraced from each other, the return value will be of the data type with the higher precision. For example, if an Integer is subtracted from a Double, the return value will be a Double value. | The return value of the following expression is 61.71.
|
time x - integer y | When an Integer value is subtracted from an Time value, the return value will be a Time value because the Integer value will have changed into a Time value. | If the time is 10:10:10, the return value of the following statement is 10:10:08.
|
time x - time y | When a Time value is subtracted from a Time value, the return value will be an Integer. The result is the number of seconds between the two times. | If one time is 08:08:08, and the other time is 10:10:10, the return value of the following statement is 7322.
|
currency x * currency y | Multiplies x by y. When a Currency value is multiplied by a Currency value, the return value will be a Currency value. | The return value of the following statement is 2.88.
|
currency x * integer y | Multiplies x by y. When a Currency value is multiplied by an Integer value, the return value will be a Currency value. | The return value of the following statement is 106.75.
|
currency x * number y | Multiplies x by y. When a Currency value is multiplied by a Number value, the return value will be a Currency value. | The return value of the following statement is 3.25.
|
integer x * currency y | Multiplies x by y. When an Integer value is multiplied by a Currency value, the return value will be a Currency value. | The return value of the following statement is 106.75.
|
integer x * integer y | Multiplies x by y. When an Integer value is multiplied by an Integer value, the return value will be an Integer value. | The return value of the following statement is 15.
|
integer x * number y | Multiplies x by y. When an Integer value is multiplied by a Number value, the return value will be a Number value. | The return value of the following statement is 104.25.
|
number x * currency y | Multiplies x by y. When a Number value is multiplied by a Currency value, the return value will be a Currency value. | The return value of the following statement is 3.25.
|
number x * integer y | Multiplies x by y. When a Number value is multiplied by an Integer value, the return value will be a Number value. | The return value of the following statement is 104.25.
|
number x * number y | Multiplies x by y. When a Number value is multiplied by a Number value, the return value will be a Number value. | The return value of the following statement is 2.88.
|
currency x / currency y | Divides x by y. When a Currency is divided by a Currency value, the return value will be an Integer or a Currency value. | The return value of the following statement is 1.77.
|
currency x / integer y | Divides x by y. When a Currency is divided by an Integer, the return value will be a Currency value. | The return value of the following statement is 1.28.
|
currency x / number y | Divides x by y. When a Currency is divided by a Number value, the return value will be an Integer or a Currency value. | The return value of the following statement is 1.79.
|
integer x / currency y | Divides x by y. When an Integer is divided by a Currency value, the return value will be a Currency or an Integer. | The return value of the following statement is 21.87.
|
integer x / integer y | Divides x by y. When an Integer is divided by an Integer, the return value will be an Integer or a Number value. |
|
integer x / number y | Divides x by y. When an Integer is divided by a Number value, the return value will be a Number or an Integer. | The return value of the following statement is 21.88.
|
number x / currency y | Divides x by y. When a Number is divided by a Currency value, the return value will be a Currency value. | The return value of the following statement is 1.77.
|
number x / integer y | Divides x by y. When a Number is divided by an Integer, the return value will be a Number value. | The return value of the following statement is 0.51.
|
number x / number y | Divides x by y. When a Number is divided by a Number value, the return value will be an Integer or a Number value. | The return value of the following statement is 1.77.
|
number x \ number y | Divides x by y, and returns an Integer result. |
|
currency -x | Returns the opposite value of x. If a Currency value is positive, the return value will be negative. If the Currency value is negative, the return value will be positive. |
|
integer -x | Returns the opposite value of x. If an Integer value is positive, the return value will be negative. If the Integer value is negative, the return value will be positive. |
|
number -x | Returns the opposite value of x. If a Number value is positive, the return value will be negative. If the Number value is negative, the return value will be positive. |
|
currency x % currency y | Computes the percentage of dividing x by y. When a Currency value is divided by a Currency value, the return value will be an Integer or a Currency. | The return value of the following statement is 176.56.
|
currency x % integer y | Computes the percentage of dividing x by y. When a Currency value is divided by an Integer value, the return value will be an Integer or a Currency. | The return value of the following statement is 226.
|
currency x % number y | Computes the percentage of dividing x by y. When a Currency value is divided by a Number value, the return value will be an Integer or a Currency. | The return value of the following statement is 120.
|
integer x % currency y | Computes the percentage of dividing x by y. When an Integer value is divided by a Currency, the return value will be an Integer or a Currency. | The return value of the following statement is 40.
|
integer x % integer y | Computes the percentage of dividing x by y. When an Integer value is divided by an Integer, the return value will be an Integer or a Number. | The return value of the following statement is 77.78.
|
integer x % number y | Computes the percentage of dividing x by y. When an Integer value is divided by a Number, the return value will be a Number or an Integer. | The return value of the following statement is 400.
|
number x % currency y | Computes the percentage of dividing x by y. When a Number value is divided by a Currency, the return value will be an Integer or a Currency value. | The return value of the following statement is 500.
|
number x % integer y | Computes the percentage of dividing x by y. When a Number value is divided by an Integer, the return value will be an Integer or a Number. | The return value of the following statement is 50.
|
number x % number y | Computes the percentage of dividing x by y. When a Number value is divided by a Number, the return value will be an Integer or a Number. | The return value of the following statement is 176.56.
|
number x ^ number y | Raise x to the power of y. y can be fractional, positive or negative. x can be fractional, but negative only when y is a whole number. |
|
number x \ number y | Divides x by y after rounding them to the nearest integer if they are not, and returns an Integer number. |
|
Comparison
Operator | Description | Example |
---|---|---|
date x > date y | If x is greater than y, the return value will be true. If x is < and == y, the return value will be false. | The return value of the following statement is true.
|
datetime x > datetime y | If x is greater than y, the return value will be true. If x is < and == y, the return value will be false. | The return value of the following statement is true.
|
numeric x > numeric y | If x is greater than y, the return value will be true. If x is < and == y, the return value will be false. |
|
string x > string y | If x is greater than y, the return value will be true. If x is < and == y, the return value will be false. |
|
time x > time y | If x is greater than y, the return value will be true. If x is < and == y, the return value will be false. | The return value of the following statement is true.
|
date x < date y | If x is less than y, the return value will be true. If x is > and == y, the return value will be false. | The return value of the following statement is false.
|
datetime < datetime y | If x is less than y, the return value will be true. If x is > and == y, the return value will be false. | The return value of the following statement is false.
|
numeric x < numeric y | If x is less than y, the return value will be true. If x is > and == y, the return value will be false. |
|
string x < string y | If x is less than y, the return value will be true. If x is > and == y, the return value will be false. |
|
time x < time y | If x is less than y, the return value will be true. If x is > and == y, the return value will be false. | The return value of the following statement is false.
|
date x == date y | If x is equal to y, the return value is true. If x is not equal to y, the return value will be false. | The return value of the following statement is false.
|
datetime x == datetime y | If x is equal to y, the return value will be true. If x is not equal to y, the return value will be false. | The return value of the following statement is false.
|
numeric x == numeric y | If x is equal to y, the return value will be true. If x is not equal to y, the return value will be false. | The return value of the following statement is false.
|
string x == string y | If x is equal to y, the return value is true. If x is not equal to y, the return value will be false. | The return value of the following statement is false.
|
time x == time y | If x is equal to y, the return value will be true. If x is not equal to y, the return value will be false. | The return value of the following statement is false.
|
date x <> date y or date x != date y | If x is not equal to y, the return value will be true. If x is equal to y, the return value will be false. | The return value of the following statement is true.
|
datetime x <> datetime y or datetime x != datetime y | If x is not equal to y, the return value will be true. If x is equal to y, the return value will be false. | The return value of the following statement is true.
|
numeric x <> numeric y or numeric x != numeric y | If x is not equal to y, the return value will be true. If x is equal to y, the return value will be false. | The return value of the following statement is false.
|
string x <> string y or string x != string y | If x is not equal to y, the return value will be true. If x is equal to y, the return value will be false. | The return value of the following statement is true.
|
time x <> time y or time x != time y | If x is not equal to y, the return value will be true. If x is equal to y, the return value will be false. | The return value of the following statement is true.
|
Boolean
Below is a set of truth tables showing the logic operations for 3-valued logic.
A AND B | True | False | Null |
---|---|---|---|
True | True | False | Null |
False | False | False | False |
Null | Null | False | Null |
A OR B | True | False | Null |
---|---|---|---|
True | True | True | True |
False | True | False | Null |
Null | True | Null | Null |
A | NOT A |
---|---|
True | False |
False | True |
Null | Null |
Boolean operators are explained as follows:
Operator | Description | Example |
---|---|---|
Boolean x || Boolean y | Returns true if x is true or y is true. |
|
Boolean x && Boolean y | Returns true if x is true and y is true. |
|
! Boolean x | Returns true if x is false. | The return value of the following statement is def.
|
Others
Operator | Description | Example |
---|---|---|
x in y | A statement used to tell whether x is in y, the return value is a boolean value. |
|
[x, y, z] | A statement used to define an array. | The return value of the following statement is 1996-11-27.
|
x[i] | A statement used to index a certain value in an array. | The return value of the following statement is 14:11:27.
|
x[i to j] | A statement used to define an array. | The return value of the following statement is true.
|
x[i _to j] | It is used to specify a range of values greater than but not including the value i, and less than or equal to the value j. Both i and j are the type of Number. | The return value of the following statement is true.
|
x[i to_ j] | It is used to specify a range of values greater than or equal to the value i, and less than but not including the j value. Both i and j are the type of Number. | The return value of the following statement is true.
|
x[i _to_ j] | It is used to specify a range of values greater than but not including the value i, and less than but not including the value j. Both i and j are the type of Number | The return value of the following statement is true.
|
x[upfrom j] | It is used to specify a range of values greater than or equal to the value j. j is the type of Number. | The return value of the following statement is false.
|
x[upfrom_ j] | It is used to specify a range of values greater than but not including the value j. j is the type of Number. | The return value of the following statement is true.
|
x[upto j] | It is used to specify a range of values less than or equal to the value j. j is the type of Number. | The return value of the following statement is true.
|
x[upto_ j] | It is used to specify a range of values less than but not including the value j. j is the type of Number. | The return value of the following statement is false.
|
if(b) then{...} else{...} | Conditional statement. | The return value of the following statement is abc.
|
return x | Returns the value of X. | The result of the following statement is 06/19/01.
|