Mysql datetime取日期day,取每月最后一天,取每月天数

Posted 二十六画生的博客

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mysql datetime取日期day,取每月最后一天,取每月天数相关的知识,希望对你有一定的参考价值。

mysql> select day('2020-01-01 18:10:10')
    -> ;
+----------------------------+
| day('2020-01-01 18:10:10') |
+----------------------------+
|                          1 |
+----------------------------+
1 row in set (0.00 sec)

mysql> select day('2020-01-21 18:10:10')
    -> ;
+----------------------------+
| day('2020-01-21 18:10:10') |
+----------------------------+
|                         21 |
+----------------------------+
1 row in set (0.00 sec)

mysql> select day('2020-10-21 18:10:10')
    -> ;
+----------------------------+
| day('2020-10-21 18:10:10') |
+----------------------------+
|                         21 |
+----------------------------+
1 row in set (0.00 sec)

mysql> select last_day('2021-01-01 12:12:01');
+---------------------------------+
| last_day('2021-01-01 12:12:01') |
+---------------------------------+
| 2021-01-31                      |
+---------------------------------+
1 row in set (0.00 sec)

mysql> ;
ERROR: 
No query specified

mysql> select last_day('2021-09-01 12:12:01');
+---------------------------------+
| last_day('2021-09-01 12:12:01') |
+---------------------------------+
| 2021-09-30                      |
+---------------------------------+
1 row in set (0.00 sec)

mysql> 

以上是关于Mysql datetime取日期day,取每月最后一天,取每月天数的主要内容,如果未能解决你的问题,请参考以下文章