oracle sql日期比较 .

在某某日期之前:

select * from tableName where dateColm <= to_date('2012-06-14','yyyy-mm-dd');
select * from tableName where dateColm <= to_date('2012-06-14 00:00','yyyy-mm-dd hh24:mi');
select * from tableName where dateColm <= to_date('2012-06-14 00:00:00','yyyy-mm-dd hh24:mi:ss');

 在某某日期之后:

select * from tableName where dateColm >= to_date('2012-06-14','yyyy-mm-dd');

等于某个日期(可精确到时分秒):

select * from tableName where dateColm = to_date('2012-06-14','yyyy-mm-dd');
select * from tableName where dateColm = to_date('2012-06-14 00:00','yyyy-mm-dd hh24:mi');
select * from tableName where dateColm = to_date('2012-06-14 00:00:00','yyyy-mm-dd hh24:mi:ss');

 在某个时间段范围内:

<pre class="sql" name="code">select * from tableName where dateColm between to_date('2012-06-14 00:00:00','yyyy-mm-dd hh24:mi:ss') and to_date('2012-06-24 00:00:00','yyyy-mm-dd hh24:mi:ss');
select * from tableName where dateColm >= to_date('2012-06-14 00:00:00','yyyy-mm-dd hh24:mi:ss') and dateColm <= to_date('2012-06-24 00:00:00','yyyy-mm-dd hh24:mi:ss');

猜你喜欢

转载自fantasy0407.iteye.com/blog/1560632