在ACCESS数据库中一个字段是日期型,并且保存完整的时间,包含年 月 日 小时 分 秒。
搜索时需要找出 年 月 日 满足条件的记录,应该怎么用 LIKE ?

解决方案 »

  1.   

    select * from tablename where ddate between #2007-1-1 00:00:01# and #2007-1-4 23:59:59#
      

  2.   

    可以在SQL查询中把日期型转化为固定格式的字符串,这样不只可以查询某日的,也可以查询某年的,某月的,某时的,某秒的,因为本人一直在SQLServer2000下编程,不知道ACCESS相关的SQL函数,还请高手们来给出这些函数吧
        在SQL Server 2000中这样写:
        select * from 表名 where convert(char(10),日期字段,120)='2007-01-05'
      

  3.   

    access用format:select * from tb
    where format(youDate,"yyyy-mm")='2006-12'
      

  4.   

    access用format:select * from tb
    where format(youDate,"yyyy-mm-dd")='2006-12-25'
      

  5.   

    vbman2003(家人) 按照你的写法,提示类型不匹配,是不是因为日期字段中有空值呢?
      

  6.   

    可以添加条件:
     and not 日期字段 is null
      

  7.   

    我是这样写的,求各位老大看看哪里错了。RS.Open "select * from TB1 where " + Format([D_Field], "yyyy-mm-dd") + " ='" + Format(Now, "yyyy-mm-dd") + "'", CN, adOpenDynamic, adLockBatchOptimistic
      

  8.   

    RS.Open "select * from TB1 where Format([D_Field], 'yyyy-mm-dd') ='" + Format(Now, "yyyy-mm-dd") + "'", CN, adOpenDynamic, adLockBatchOptimistic这样才应该对,因为我没有ACCESS,所以无法调试,但是看出了你编写时的基本问题