1.1、SELECT * FROM 表名 t WHERE 1=1 AND to_date(t.tkdat,'yyyy/MM/dd')
between to_date('2017/8/1','yyyy/MM/dd') and to_date('2017/11/1','yyyy/MM/dd')
1.2、SELECT * FROM zsd018a t WHERE 1=1 AND to_date(t.tkdat,'yyyy/MM/dd hh24:mi:ss')
between to_date('2017/8/1','yyyy/MM/dd hh24:mi:ss') and to_date('2017/11/1','yyyy/MM/dd hh24:mi:ss')
2、当时间条件为date类型的时候,通过以下方法查询数据:
select * from zmm028 where to_char(tkdat,'YYYY-MM-DD')>='2017-10-01'
and to_char(tkdat,'YYYY-MM-DD')<='2017-11-02'
select * from TableA where to_char(startDate,'YYYY-MM-DD')>='2011-09-01' and to_char(endDate,'YYYY-MM-DD')<='2011-09-012'另外如果是程序里面用可以做绑定参数,免得每次都解析SQL语句,可以减少查询时间
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)