A SERVICE OF

logo

Chapter 5
|
Supported standards 39
Date operators
You can modify dates.
Examples
In the following examples, hire_date is {01/30/2004}.
Additional examples:
SELECT Date_Sold, Date_Sold + 30 AS agg FROM Sales_Data
SELECT Date_Sold, Date_Sold - 30 AS agg FROM Sales_Data
Relational operators
Examples
SELECT Sales_Data.Invoice_ID FROM Sales_Data
WHERE Sales_Data.Salesperson_ID = 'SP-1'
SELECT Sales_Data.Amount FROM Sales_Data WHERE Sales_Data.Invoice_ID <> 125
SELECT Sales_Data.Amount FROM Sales_Data WHERE Sales_Data.Amount > 3000
Operator Effect on date Example Result
+ Add a number of days to a date hire_date + 5 {02/04/2004}
- Find the number of days between two dates,
or subtract a number of days from a date
hire_date - {01/01/2004}
hire_date - 10
29
{01/20/2004}
Operator Meaning
= Equal
<> Not equal
> Greater than
>= Greater than or equal to
< Less than
<= Less than or equal to
LIKE Matching a pattern
NOT LIKE Not matching a pattern
IS NULL Equal to Null
IS NOT NULL Not equal to Null
BETWEEN Range of values between a lower and upper bound
IN A member of a set of specified values or a member of a subquery
NOT IN Not a member of a set of specified values or a member of a subquery
EXISTS ‘True’ if a subquery returned at least one record
ANY Compares a value to each value returned by a subquery (operator must be preceded by =,
<>, >, >=, <, or <=); =Any is equivalent to In
ALL Compares a value to each value returned by a subquery (operator must be preceded by =,
<>, >, >=, <, or <=)