zoukankan      html  css  js  c++  java
  • oracle时间范围查询

    当时间精确到秒的指标和时间精确到日的时间进行对比是恒不等于的,但是可以判断大于或者等于的情况。

    举个例子,指标【时间精确到秒】

    select 时间精确到秒 
    from table
    where 时间精确到秒<= to_date('2013-11-20 ', 'yyyy-MM-dd ')
    and 时间精确到秒 >= to_date('2013-11-20 ', 'yyyy-MM-dd ')

    明显数据查询2013-11-20那天没有数据,而如果sql如下写发现数据库中是存在数据的。

    select 时间精确到秒 
    from table
    where to_date(to_char(时间精确到秒,'yyyy-MM-dd'),'yyyy-MM-dd') <= to_date('2013-11-21 ', 'yyyy-MM-dd ')
    and to_date(to_char(时间精确到秒,'yyyy-MM-dd'),'yyyy-MM-dd') >= to_date('2013-11-20 ', 'yyyy-MM-dd ')

    因此,我们可以得出结论:

    当【时间指标精确到秒】与【时间精确到日】的对比进行范围查询时不能查询当天的数据,因此必须对【时间指标精确到秒】进行格式转换成到日的时间格式。

  • 相关阅读:
    BZOJ1040: [ZJOI2008]骑士
    酱油记:GDKOI2018
    BZOJ1800: [Ahoi2009]fly 飞行棋
    BZOJ3894: 文理分科
    树链剖分
    文件格式问题
    10.23模拟赛
    snakes
    数据结构题目
    jquery&nbsp;easyui&nbsp;datebox&nbsp;的使用&nbsp;.
  • 原文地址:https://www.cnblogs.com/zhutouying/p/3435810.html
Copyright © 2011-2022 走看看