第一种方法:查询2018年1月到2018年10月的数据
select * from 表名 where times between “2018-01-01” and “2018-10-31”;
第二种方法:查询2018年1月到2018年10月的数据(使用 “%”)
select * from 表名 where times between “2018-01%” and “2018-11%”;
注:between …and 语法中使用“%”模糊查询日期,后面的日期需要+1;如果sql语句为:select * from 表名 where times between “2018-01%” and “2018-10%”,则sql语句查询的时间为2018-1月到2018年9月的数据信息
更多推荐
关于sql语句中日期的查询
发布评论