让我们首先创建一个表-
create table DemoTable( ArrivalDate timestamp );
使用插入命令在表中插入一些记录-
insert into DemoTable values('2019-09-14 17:25:00'); insert into DemoTable values('2019-09-13 17:25:00'); insert into DemoTable values('2016-09-01 17:20:10'); insert into DemoTable values('2019-09-11 12:00:00');
使用select语句显示表中的所有记录-
select *from DemoTable;
这将产生以下输出-
+---------------------+ | ArrivalDate | +---------------------+ | 2019-09-14 17:25:00 | | 2019-09-13 17:25:00 | | 2016-09-01 17:20:10 | | 2019-09-11 12:00:00 | +---------------------+ 4 rows in set (0.04 sec)
以下是查询以显示当前日期之前的时间戳-
select *from DemoTable where ArrivalDate < now();
这将产生以下输出-
+---------------------+ | ArrivalDate | +---------------------+ | 2019-09-13 17:25:00 | | 2016-09-01 17:20:10 | | 2019-09-11 12:00:00 | +---------------------+ 3 rows in set (0.07 sec)