在我的表中有一个字段存储的是datetime格式“yyyy-mm-dd hh24:mi:ss”。
我想获得10月1号到10月31号之间 早上6点到早上9点之间的数据。请问大侠们 如何写语句啊???
  

解决方案 »

  1.   

    select * from your_table 
    where (to_number(to_char(your_date_column,'mi'))  between 6 and 9)
    and (your_date_column between to_date('20101001','yyyymmdd') and to_date('20101101','yyyymmdd'))
      

  2.   

    select * from tablename 
    where to_char(col,'dd') between 1 and 31 
    and to_char(col,'hh24') between 6 and 9
      

  3.   

    select * from your_table  
    where (to_number(to_char(your_date_column,'hh24')) between 6 and 9)
    and (your_date_column between to_date('20101001','yyyymmdd') and to_date('20101101','yyyymmdd')) 
     
      

  4.   

    缺少月份select * from tablename 
    where to_char(col,'mm')='10' 
    and to_char(col,'dd') between 1 and 31 
    and to_char(col,'hh24') between 6 and 9
      

  5.   

    写错了时间
    select * from your_table  
    where (to_number(to_char(your_date_column,'hh24')) between 6 and 9)
    and (your_date_column between to_date('20101001','yyyymmdd') and to_date('20101101','yyyymmdd'))
      

  6.   

    谢谢提醒
    select * from tablename 
    where to_char(col,'yyyymmdd') between 20101001 and 20101031 
    and to_char(col,'hh24') between 6 and 9
      

  7.   


    --dateti
    --20100909 151515
    --20101015 161616
    --20111001 171717
    --20101015 070707
    --sql
    select * from yyq_date  
    where (to_number(to_char(dateti,'hh24')) between 6 and 9)
    and (dateti between to_date('20101001','yyyymmdd') and to_date('20101101','yyyymmdd'))
    ---------------------------------------------------------------------------------------
    2010/10/15 07:07:07