Export (0) Print
Expand All

- (Subtract)

SQL Server 2000

Subtracts two numbers. This subtraction arithmetic operator can also subtract a number, in days, from a date.

Syntax
expression - expression
Arguments
expression
Is any valid expression Microsoft® SQL Server™ 2000 Windows® CE Edition (SQL Server CE) of any of the data types of the numeric data type category, except the bit data type.
Result Types

Returns the data type of the argument with the higher precedence.

Examples

The following example uses the subtraction arithmetic operator to get the number of days between the time a Northwind customer placed an order and when the order was shipped.

SELECT (DATEPART(day, ShippedDate) - DATEPART(day, OrderDate)) FROM Orders WHERE OrderID = '10248'
--The value returned is '12'.

Show:
© 2014 Microsoft