Nous pouvons utiliser des opérateurs arithmétiques (+, -, *, /) avec la valeur unitaire du mot-clé INTERVAL comme suit -
mysql> Select date('2017-10-22' + INTERVAL 2+2 Year) AS 'Date After (2+2)Years'; +------------------------+ | Date After (2+2) Years | +------------------------+ | 2021-10-22 | +------------------------+ 1 row in set (0.00 sec)
mysql> Select date('2017-10-22' + INTERVAL 2-2 Year) AS 'Date After (2-2)Years'; +------------------------+ | Date After (2-2) Years | +------------------------+ | 2017-10-22 | +------------------------+ 1 row in set (0.00 sec)
mysql> Select date('2017-10-22' + INTERVAL 2*2 Year) AS 'Date After (2*2)Years'; +------------------------+ | Date After (2*2) Years | +------------------------+ | 2021-10-22 | +------------------------+ 1 row in set (0.00 sec)
mysql> Select date('2017-10-22' + INTERVAL 2/2 Year) AS 'Date After (2/2) Years'; +------------------------+ | Date After (2/2) Years | +------------------------+ | 2018-10-22 | +------------------------+ 1 row in set (0.00 sec)
Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!