您现在的位置是:主页 > news > html5网站制作/网站优化推广公司排名
html5网站制作/网站优化推广公司排名
admin2025/4/27 22:22:38【news】
简介html5网站制作,网站优化推广公司排名,黄页推广有限公司,wordpress 单词被打断要计算日期范围内的天数,您需要使用来查找日期之间的差额DATEDIFF()。让我们首先创建一个表:mysql> create table DemoTable730 (StartDate date,EndDate date);使用insert命令在表中插入一些记录:mysql> insert into DemoTable730 val…
要计算日期范围内的天数,您需要使用来查找日期之间的差额DATEDIFF()。
让我们首先创建一个表:mysql> create table DemoTable730 (
StartDate date,
EndDate date
);
使用insert命令在表中插入一些记录:mysql> insert into DemoTable730 values('2019-01-21','2019-07-21');
mysql> insert into DemoTable730 values('2018-10-11','2018-12-31');
mysql> insert into DemoTable730 values('2016-01-01','2016-12-31');
使用select语句显示表中的所有记录:mysql> select *from DemoTable730;
这将产生以下输出-+------------+------------+
| StartDate | EndDate |
+------------+------------+
| 2019-01-21 | 2019-07-21 |
| 2018-10-11 | 2018-12-31 |
| 2016-01-01 | 2016-12-31 |
+------------+------------+
3 rows in set (0.00 sec)
以下是查询日期范围内的天数的查询:mysql> select ABS(DATEDIFF(StartDate,EndDate)) AS Days from DemoTable730;
这将产生以下输出-+------+
| Days |
+------+
| 181 |
| 81 |
| 365 |
+------+
3 rows in set (0.00 sec)