Subtraction ( - )

What is it?

Subtraction takes two operands and reduces the value of the first operand by the value of the second. Applying the subtraction operator to a single operand will convert a negative figure to a positive, and vice versa. This is known as Negation.

What is the Syntax?

Binary subtraction syntax is as follows:

Operand1 – Operand2

Unary subtraction syntax is as follows:

–Operand

Why might I want to use this?

  • Subtracting purchased stock from standing stock to keep track of remaining stock.
  • Deducting tax and other deductions from a gross salary to work out your net payment.
  • Subtracting someone’s birth date from the current date to calculate their age.

In the following example, you want to subtract the date an order was placed from the date the order was shipped, to establish how many days elapsed between those dates.

ShippingDelay := ShippedDate - OrderDate

If the value of ShippedDate is 24th April 2012 and the value of OrderDate is 20th April 2012, the result of this subtraction will be 4.

 

<< Previous: Addition ( + ) | Next: Multiplication ( * ) >>