Mega Code Archive

 
Categories / MySQL / Date Time
 

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)