当前位置: 代码迷 >> SQL >> oracle sql日期比较
  详细解决方案

oracle sql日期比较

热度:69   发布时间:2016-05-05 15:14:26.0
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');

?

  相关解决方案