时间判断

字段里面的信息

2014-7-4 14:25:06

数据表里有很多条数据,要找出时间在12:30:15到14:30:21的所有字段

求完整sql语句

阅读 3.7k
2 个回答
select * from table
where CAST(field as time) > CAST('12:30:15' as time)
and CAST(field as time) < CAST('14:30:21' as time)

oracle中的写法,首先要求是你的字段名field_name需要是date类型,不是的话自己转一下

    select * from table
    where to_date(to_char(field_name,'hh24:mi:ss'),'hh24:mi:ss') 
    between 
        to_date('12:30:15','hh24:mi:ss')
     and 
        to_date('14:30:21','hh24:mi:ss')
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题