Difference between revisions of "SQL Date operators"

From Lianjapedia
Jump to: navigation, search
 
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
 
Date operators
 
Date operators
 
  
 
==Syntax==
 
==Syntax==
 
<expression1> operator <expression2>[ operator <expression3>…]
 
<expression1> operator <expression2>[ operator <expression3>…]
 
  
 
==See Also==
 
==See Also==
 
[[SQL INSERT|INSERT]], [[SQL OPERATORS]], [[SQL SELECT|SELECT]], [[SQL UPDATE|UPDATE]]
 
[[SQL INSERT|INSERT]], [[SQL OPERATORS]], [[SQL SELECT|SELECT]], [[SQL UPDATE|UPDATE]]
 
  
 
==Description==
 
==Description==
 
Operators used with Date expressions and Date/Numeric expressions:
 
Operators used with Date expressions and Date/Numeric expressions:
  
 
+
{| class="wikitable" width="100%"
 
+
{| class="wikitable"
+
 
!Operator||Expression1||Expression2||Operation
 
!Operator||Expression1||Expression2||Operation
 
|-
 
|-
|<nowiki>+</nowiki>||Date||Numeric||Adds the <expression2> number of days to the date and returns a date
+
|valign="top"|<nowiki>+</nowiki>||valign="top"|Date||valign="top"|Numeric||Adds the <expression2> number of days to the date and returns a date
 
|-
 
|-
|<nowiki>-</nowiki>||Date||Numeric||Subtracts the <expression2> number of days from the date and returns a date
+
|valign="top"|<nowiki>-</nowiki>||valign="top"|Date||valign="top"|Numeric||Subtracts the <expression2> number of days from the date and returns a date
 
|-
 
|-
|<nowiki>-</nowiki>||Date||Date||Returns a numeric signifying the number of days between the two dates.  If <expression2> is later, a negative number is returned
+
|valign="top"|<nowiki>-</nowiki>||valign="top"|Date||valign="top"|Date||Returns a numeric signifying the number of days between the two dates.  If <expression2> is later, a negative number is returned
 
|-
 
|-
 
|}
 
|}
 
  
 
==Example==
 
==Example==
Line 36: Line 30:
  
  
==Products==
 
Recital, Recital Server
 
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:SQL|Operators,Date]]
 
[[Category:SQL|Operators,Date]]

Latest revision as of 11:34, 30 January 2013

Purpose

Date operators

Syntax

<expression1> operator <expression2>[ operator <expression3>…]

See Also

INSERT, SQL OPERATORS, SELECT, UPDATE

Description

Operators used with Date expressions and Date/Numeric expressions:

Operator Expression1 Expression2 Operation
+ Date Numeric Adds the <expression2> number of days to the date and returns a date
- Date Numeric Subtracts the <expression2> number of days from the date and returns a date
- Date Date Returns a numeric signifying the number of days between the two dates. If <expression2> is later, a negative number is returned

Example

SELECT account_no, ord_date – rec_date as "Delivery Delay";
FROM accounts;
ORDER BY account_no