字段是日期时间型
字段是outdate如何
text1=2003-5-21
text2=2003-5-24
sql = "select * from out where outdate>=" & Text1 & " and outdate<=" & Text2 & " order by outdate desc"
不能查找出
datetime 2003-5-26 8:59:56的数据请问是怎么回事

解决方案 »

  1.   

    text1=cdate("2003-5-21")
    text2=cdate("2003-5-24")
    sql = "select * from out where outdate>=" & Text1 & " and outdate<=" & Text2 & " order by outdate desc"
      

  2.   

    '如果数据库为ACCESS:
      sql = "select * from out where outdate between # " & Text1 & " # and # " & Text2 & # " order by outdate desc"
    '如果数据库为SQL:
        sql = "select * from out where outdate between '" & Text1 & "' and '" & Text2 & "' order by outdate desc"
      

  3.   

    楼上的有错吧'如果数据库为ACCESS:
      sql = "select * from out where outdate between # " & Text1 & " # and # " & Text2 & # " order by outdate desc"
    '如果数据库为SQL:
        sql = "select * from out where outdate between " & Text1 & " and " & Text2 & " order by outdate desc"