4.8 Arithmetic Operators

The + and - arithmetic operators can be used on numeric format strings as well as date and character format strings. The data format is shown in Table 4.5.

Table 4.5: Summary of arithmetic operators

Operator

Format

Description

Example

Addition(+)

$num_1+num_2$

Addition of numeric values

1.5+2.3 (3.8)

 

$str_1+str_2$

Join character strings

"150"+"円" ("150円")

 

$date+num$

$num$ days after date

0d20121130+2 (0d20121202)

 

$time+num$

$num$ seconds after time

0t095959+2 (0t100001)

Substraction(-)

$num_1-num_2$

Subtraction of numeric values

1.5-2.3 (-1.8)

 

$str_1-str_2$

Remove substring

"aababa"-"a" ("bb")

   

(by greedy match algorithm)

"aababa"-"aba" ("aba")

 

$date-num$

$num$ days before date

0d20121202-2 (0d20121130)

 

$time-num$

$num$ seconds before time

0t100001-2 (0t095959)

 

$date_1-date_2$

Date difference

0d20121202-0d20121130 (2)

 

$time_1-time_2$

Time difference

0t095959-0t100001 (-2)

Multiplication (*)

$num_1*num_2$

multiply

10*2 (20)

Division (/)

$num_1/num_2$

divide

10/2 (5)

Remainder (%)

$num_1\% num_2$

remainder

10%3 (1)

Power (\^{})

$num_1$\^{}$num_2$

power

10^3 (1000)


The results of the examples are shown in parentheses (the content is shown using constant numbers).