如:"select * from dd where rq =#" & rqdata & "#"
rqdata="2003-12-12" 或者"03-12-12"
在WIN2000中可到结果,但在WIN98中一样的语句,在数据库里查询不到结果,请问怎么解决?请详细说明!

解决方案 »

  1.   

    Win2000与Win98的日期格式是不一样的,你可以将Win98的日期格式设为与Win200一致。方法:控制面板——》区域设置--》日期当然你也可以直接这样:
    select * from dd where rq =#" & format(rqdata,"yyyy-MM-dd") & "#" (如果是sqlserver数据库,那么须将#换成')
      

  2.   

    我原来也遇见过日期查询的问题
    你试试
    不用条件
    查询
    输出日期字段值(可用断点调试,跟踪变量值)看格式,究竟是哪几个字符,什排列格式
    yyyy-mm-dd
    yy-mm-dd
    mm-dd-yyyy
    mm-dd-yy对我原来 就是这样解决的
      

  3.   

    sql win2000中
    select * from dd where rq ='" & format(rqdata,"yyyy-MM-dd") & "'"
      

  4.   

    If Option3.Value Then
                      If Text4.Text = "" Or Text5.Text = "" Or Len(Text4.Text) < 4 Then
                         MsgBox "请您完整填写查询时间!", vbOKOnly + vbInformation, "查询"
                      Exit Sub
                      End If
                     wherestr = wherestr + "出生日期 < '" & Text4.Text & "-" & Text5.Text & "-" & 1 & "'"
                   End If
                   If Option4.Value Then
                      If Text4.Text = "" Or Text5.Text = "" Or Len(Text4.Text) < 4 Then
                        MsgBox "请您完整填写查询时间!", vbOKOnly + vbInformation, "查询"
                      Exit Sub
                      Else
                        wherestr = wherestr + "出生日期 >'" & Trim$(Text4.Text) & "-" & Trim$(Text5.Text) & "-" & 31 & "'"
                      End If
                   End If
            
                   If Option5.Value Then
                      If Text4.Text = " " Or Text5.Text = " " Or Text8.Text = "" Or Text9.Text = "" Or Len(Text4.Text) < 4 Or Len(Text8.Text) < 4 Then
                         MsgBox "请您完整填写查询时间!", vbOKOnly + vbInformation, "查询"
                      Exit Sub
                      Else
                        wherestr = wherestr + "出生日期 Between '" & Text4.Text & "-" & Text5.Text & "-" & 1 & "' And '" & Text8.Text & "-" & Text9.Text & "-" & 1 & "'"
                      End If
                   End If
      

  5.   

    为什么不用格式化函数先将rqdata格式化成系统可以识别的日期格式?这只是我的想法,不一定正确
      

  6.   

    如果是我做,我就用format转换格式~~~不知道这样做是否正确~~
      

  7.   

    在ACCESS中使用where data_field=cdate("datastring")
      

  8.   

    您可以在 SQL 子句中使用 Datepart(year,datefield)=年,Datepart(month,datefield)=月,Datepart(day,datefield)=日