程序中有一控件DTPicker1格式为“yyyy-mm-dd”,将内容保存到test表后
执行rs.open "select * from test where test_date=#" & DTPicker1.value & "#",cn,1,1
当操作系统的日期格式为"yyyy-mm-dd"时可查找到满足条件的记录
当操作系统的日期格式为"yy-m-d"时查不到,可能原因是"2005-4-11"和"05-4-11"的值不同,各位高手有什么办法可解决不操作系统日期格式不定的情况下查找都可得到同样的结果吗?

解决方案 »

  1.   

    把查找出来的时间和系统时间都Format一下。
    看看MSDN的Format函数就知道了。
      

  2.   

    我用rs.open "select * from test where format(test_date,'yyyy-mm-dd')=#" & format(DtPicker1.value,"yyyy-mm-dd")  & "#",cn,1,1
    但还是不行,楼主可不可以帮写一句
      

  3.   

    rs.open "select * from test where test_date=#" & Format(DTPicker1.Value, "yyyy-mm-dd") & _
    "# or test_date = #" & Format(DTPicker1.Value, "yy-m-d") & "#", cn, 1, 1加了个or 语句,随便写了一下,应该可以实现楼主的要求