The INTERVAL() function compares the first integer listed as an argument to the integers that follow the first : INTERVAL « Date Time « SQL / MySQL






The INTERVAL() function compares the first integer listed as an argument to the integers that follow the first

    
 integer.
mysql>
The following syntax shows how to use this function: INTERVAL(<integer1>, <integer2> [{, <integer>}...])
mysql>
Starting with <integer2>, the values must be listed in ascending order.
mysql>
If <integer1> is less than <integer2>, a value of 0 is returned.
If <integer1> is less than <integer3>, a value of 1 is returned.
If <integer1> is less than <integer4>, a value of 2 is returned, and so on.
mysql>
mysql>
mysql> SELECT INTERVAL(6, -2, 0, 4, 7, 10, 12);
+----------------------------------+
| INTERVAL(6, -2, 0, 4, 7, 10, 12) |
+----------------------------------+
|                                3 |
+----------------------------------+
1 row in set (0.00 sec)

   
    
    
    
  








Related examples in the same category

1.The INTERVAL clause requires an , which must be a time value in an acceptable format, and a value.
2.Calculating Intervals Between Times
3.Adding a Temporal Interval to a Time
4.Literal for timestamp type column
5.Some interval specifiers comprise both date and time parts.
6.Use the + and - operators to perform date interval addition and subtraction
7.Add date with interval
8.Get the date seven days after the payment date.
9.Add 7 day interval to a date
10.Add Month and day to a date
11.Add hour, seconds and microseconds to Date
12.Add one day to the date literal '2004-13-12'; next show the error messages.
13.To convert the interval from seconds to other units, perform the appropriate division