各位高手:我用的是win2k,access,DAO,
我的数据库中有一项ubirthday是存放客户生日的,存取形式是"yyyy-mm-dd"
现在我想查找5月18日到7月18日过生日的客户信息。
我写的语句如下:date1="2004-5-18"
date2="2004-7-18"
sqlstr = "select * from table1 where Format(ubirthday, 'mm-dd') > #" & Format(date1, "mm-dd") & "# and Format(ubirthday, 'mm-dd') < #" & Format(date2, "mm-dd") & "# "
Set rs = db.OpenRecordset(sqlstr)可是什么结果也没有,程序也不报错,为什么呢,还请各位指点,如何查询出某月某日到某月某日过生日的人。十分感谢!

解决方案 »

  1.   

    不要貼程序..把執行的SQL貼出來看看吧.這樣沒有辦法判斷是什麼錯誤.
      

  2.   

    试试:
    sqlstr = "select * from table1 where ubirthday Between #" & Format(date1, "mm-dd") & "# and  #" & Format(date2, "mm-dd") & "# "
      

  3.   

    vbman2003(家人)的效果跟我的一样,我单步调试了,是找不到记录
      

  4.   

    输入具体时间试试,date1是变量吧?
      

  5.   

    很简单,只要把“#”号改成“'”就可以了。如下:
    sqlstr = "select * from table1 where Format(ubirthday, 'mm-dd') > '" & Format(date1, "mm-dd") & "' and Format(ubirthday, 'mm-dd') < '" & Format(date2, "mm-dd") & "' "
      

  6.   

    如果字段ubirthday是文本类型,可以改#为'号试试。
      

  7.   

    同意gzhiceberg(天晓得)的方法!