Operator subtract ( - )

numeric op1 - numeric op2

Subtracts Op2 from Op1, and numeric subtracts 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 subtracts each other, the return value will be of the data type with the higher precision. For example, if an Integer subtracts a Double, the return value will be a Double value.

Example

The return value of the following expression is 61.71.

87.71 - 26

date op1 - integer op2

When a Data value subtracts an Integer value, the return value will be a Data value because the Integer value will have changed into a Data value.

Example

If the date is Oct. 18, 1999, the return value of the following statement is 10/16/99.

ToDate(1999, 10, 18) - 2

time op1 - integer op2

When a Time value subtracts an Integer value, the return value will be a Time value because the Integer value will have changed into a Time value.

Example

If the time is 10:10:10, the return value of the following statement is 10:10:08.

ToTime(10, 10, 10) - 2

datetime op1 - integer op2

When a DateTime value subtracts an Integer value, the return value will be a DateTime value because the Integer value will have changed into a DateTime value.

Example

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.

ToDateTime(1999, 10, 18, 10, 10, 10) - 2

datetime op1 - datetime op2

When a DateTime value subtracts a DateTime value, the return value will be an Integer. The result is the number of seconds between the two DateTimes.

Example

If one timestamp is 1999-12-12 10:10:10, and the other timestamp is 1995-12-12 10:10:10, the return value of the following statement is 126230400.

ToDateTime(1999, 12, 12, 10, 10, 10) - ToDateTime(1995, 12, 12, 10, 10, 10)

date op1 - date op2

When a Data value subtracts a Data value, the return value will be an Integer. The result is the number of days between the two dates.

Example

If one date is 1999-12-12, and the other date is 1995-12-12, the return value of the following statement is 1461.

ToDate(1999, 12, 12) - ToDate(1995, 12, 12)

time op1 - time op2

When a Time value subtracts a Time value, the return value will be an Integer. The result is the number of seconds between the two times.

Example

If one time is 08:08:08, and the other time is 10:10:10, the return value of the following statement is 7322.

ToTime(10, 10, 10) - ToTime(8, 8, 8)