MySQL Interval

  • MySQL interval values are used mainly for date and time calculations.

INTERVAL {value of unit} {types of interval}

  • INTERVAL is a MySQL keyword and this is case sensitive. This should be used in CAPITAL Later Only
  • {value of unit} is a expression or value like 1,2,3,4 or any expression which result in value.
  • {type of interval} is a MySQL date time unit and is described below. This show also be used in CAPITAL later only.

Type of Interval

mysql interval
mysql interval

Examples:

Query:

SELECT ‘2018-03-23’ + INTERVAL 1 DAY;

Result:

+——————————-+
| 201803-24                    |
+————————
Query:
SELECT ‘2018-03-23’ + INTERVAL -1 DAY;
+——————————–+
| 2018-03-22                     |
+——————————–+

Leave a Reply