MySQL查询要获取日期超过14天?
让我们首先创建一个-
mysql> create table DemoTable1392 -> ( -> ArrivalDate date -> );
使用insert在表中插入一些记录-
mysql> insert into DemoTable1392 values('2019-09-10');
mysql> insert into DemoTable1392 values('2019-09-26');
mysql> insert into DemoTable1392 values('2019-09-12');
mysql> insert into DemoTable1392 values('2018-09-20');
mysql> insert into DemoTable1392 values('2019-10-11');使用选择显示表中的所有记录-
mysql> select * from DemoTable1392;
这将产生以下输出-
+-------------+ | ArrivalDate | +-------------+ | 2019-09-10 | | 2019-09-26 | | 2019-09-12 | | 2018-09-20 | | 2019-10-11 | +-------------+ 5 rows in set (0.00 sec)
当前日期如下-
mysql> select curdate(); +------------+ | curdate() | +------------+ | 2019-09-26 | +------------+ 1 row in set (0.00 sec)
这是要获取14天以上的日期的查询-
mysql> select * from DemoTable1392 -> where ArrivalDate > date_sub(curdate(), interval 14 day);
这将产生以下输出-
+-------------+ | ArrivalDate | +-------------+ | 2019-09-26 | | 2019-10-11 | +-------------+ 2 rows in set (0.03 sec)
热门推荐
10 祝女儿简短祝福语大全
11 大学新年祝福语简短创意
12 元旦适合的祝福语简短
13 朋友出远门祝福语简短
14 初六简短的祝福语
15 祝男孩生日祝福语简短
16 同事调离的祝福语简短
17 拜年红包的祝福语简短
18 妈妈生日祝福语简短励志