`

oracle sql日期比较

阅读更多
--oracle sql日期比较
--在今天之前:
select * from up_date where updated_date < to_date('2015-01-15 00:00:00','yyyy-mm-dd hh24:mi:ss')
select * from up_date where updated_date <= to_date('2015-01-15 00:00:00','yyyy-mm-dd hh24:mi:ss')
--在今天之后:
select * from up_date where updated_date > to_date('2015-01-15 00:00:00','yyyy-mm-dd hh24:mi:ss')
select * from up_date where updated_date >= to_date('2015-01-15 00:00:00','yyyy-mm-dd hh24:mi:ss')
--精确时间:
select * from up_date where updated_date = to_date('2015-01-15 00:00:00','yyyy-mm-dd hh24:mi:ss')
--在某段时间内:
select * from up_date where updated_date between to_date('2014-10-15 00:00:00','yyyy-mm-dd hh24:mi:ss') and to_date('2015-01-15 00:00:00','yyyy-mm-dd hh24:mi:ss')
select * from up_date where updated_date < to_date('2015-01-15 00:00:00','yyyy-mm-dd hh24:mi:ss') and update > to_date('2014-10-15 00:00:00','yyyy-mm-dd hh24:mi:ss')
select * from up_date where updated_date <= to_date('2015-01-15 00:00:00','yyyy-mm-dd hh24:mi:ss') and update >= to_date('2014-10-15 00:00:00','yyyy-mm-dd hh24:mi:ss')
 
--当然,在实际开发中可以使用trunc函数来精确日期到天
--2015/1/15
select TRUNC(to_date('2015-01-15 00:00:00','yyyy-mm-dd hh24:mi:ss'), 'DD') from dual;
 
select * from up_date where update <= TRUNC(to_date('2015-01-15 00:00:00','yyyy-mm-dd hh24:mi:ss'), 'DD');

 

文章来源:http://www.blogjava.net/forker/archive/2007/09/07/143467.html

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics