在做查询时,pro_date是datatime类型,我输入记录2005-02-04
但pro_date为2005-02-04 00:00:00.000
而不是2005-02-04 
我的sql语句是这样写的select *from productInfo where pro_date between 2005-02-04 00:00:00.000 and 2005-02-12 00:00:00.000这样调试错误.
但写成select * from productInfo where  pro_date between 2005-02-04 and 2005-02-12有查询不出记录,
能不能在表中直接把2005-02-04 00:00:00.000转化成2005-02-04
问题怎么解决?

解决方案 »

  1.   

    oracle
    select * from productInfo where  to_date(pro_date) between to_date(2005-02-04) and to_date(2005-02-12)或者
    sql
    select * from productInfo where  pro_date between '2005-02-04' and '2005-02-12'
      

  2.   

    如果你用的是DataTimePicker的话
    在属性里有一个format属性,选择custom
    在行为里有个customformat,输入yyyy-MM-dd
      

  3.   


    select * from productInfo where pro_date between # 2005-02-04 # and # 2005-02-12 #日期查詢的格式如下書寫:
    ......where BETWEEN # "+dateTimePicker1.Text +"# AND #"+dateTimePicker2.Text+"#";
      

  4.   

    select * from productInfo where pro_date between # "2005-02-04" # and # "2005-02-12" #