Home > Database > Mysql Tutorial > How to use compound INTERVAL units in MySQL?

How to use compound INTERVAL units in MySQL?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2023-09-05 16:33:02
forward
1063 people have browsed it

How to use compound INTERVAL units in MySQL?

#The compound INTERVAL unit keyword consists of two keywords separated by an underscore (_). In order to use them in MySQL, unit values ​​must be enclosed in single quotes and separated by spaces.

Example - The following query will add 2 years and 2 months to a date value.

mysql> Select timestamp('2017-10-22 04:05:36' + INTERVAL '2 2' year_month) AS'Date After 2 Years and 2 Months';
+---------------------------------+
| Date After 2 Years and 2 Months |
+---------------------------------+
| 2019-12-22 04:05:36             |
+---------------------------------+
1 row in set (0.00 sec)
Copy after login

The above is the detailed content of How to use compound INTERVAL units in MySQL?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template