Home > Database > Mysql Tutorial > body text

How to use 2-digit year value in MySQL DATEDIFF() function?

PHPz
Release: 2023-09-05 12:09:02
forward
1273 people have browsed it

如何在 MySQL DATEDIFF() 函数中使用 2 位年份值?

We can use 2-digit year values ​​in a single date expression or in two date expressions used as parameters in the MySQL DATEDIFF() function.

For example, the following query uses a 2-digit year value in the first date expression, and the other date expressions have 4-digit year values.

mysql> Select DATEDIFF('18-10-22','2017-10-22');
+-----------------------------------+
| DATEDIFF('18-10-22','2017-10-22') |
+-----------------------------------+
|                               365 |
+-----------------------------------+
1 row in set (0.00 sec)
Copy after login

The following query uses 2-digit year values ​​in both date expressions.

mysql> Select DATEDIFF('18-10-22','17-10-22');
+---------------------------------+
| DATEDIFF('18-10-22','17-10-22') |
+---------------------------------+
|                             365 |
+---------------------------------+
1 row in set (0.00 sec)
Copy after login

The above is the detailed content of How to use 2-digit year value in MySQL DATEDIFF() function?. 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