根据时间在表中 数据结构 查询的方式不同
create table MyTest {
ID Int not null primary KEY,
createDate String null,
startDate date null,
endDate date null,
buyDate char(10) null,
useDate varchar2(20) null,
}
1、字段为字符串类型:可以直接查询,和字符串进行比较。
select * from MyTest a where a.createDate = '2017-12-15';
2、字段为 date :可以转化为字符串进行查询,和相同类型进行比较。
select * from MyTest a where a.startDate < to_date('2017-12-15','yyyy-MM-dd');
select * from MyTest a where a.startDate < to_date('2017-12-15 12:12:12','yyyy-MM-dd HH24:MI:SS');
select * from MyTest a where to_char(a.createDate,'yyyy-MM-dd') > '2017-12-15';
select to_char(a.startDate:'yyyy-MM-dd HH24:MI:SS') from MyTest a where to_date('2017-12-12':'yyyy-MM-dd') < = a.endDate;
浙公网安备 33010602011771号