select * from 表 where 时间>format(起始日期,"yyyy-mm-dd") and 时间<format(终止日期,"yyyy-mm-dd")

解决方案 »

  1.   

    可以用
    sql = "select 表名.字段名 from inandout date between" & "#" & 起始日期& "#" & "and" & "#" & 终止日期& "#"
    ‘date 是表中的字段,
      

  2.   

    select * from table where fDate between '1999-7-1' and '2002-7-1'
      

  3.   

    我说完整一些:sql server、sybase、db2这些数据库用sql = "select *  from table where '" & 起始日期 & "'" &" and  & "'" & 终止日期& "'"
    ,access数据库用 sql = "select *  from table where #" & 起始日期 & "#" &" and  & "#" & 终止日期& "#"。
      

  4.   

    应该是:
    sql server、sybase、db2这些数据库用sql = "select *  from table where fDate between '" & 起始日期 & "'" &" and  & "'" & 终止日期& "'"
    ,access数据库用 sql = "select *  from table where fDate between #" & 起始日期 & "#" &" and  & "#" & 终止日期& "#"。
      

  5.   

    seletct * from yourtablename 
    where yourdatecol between #1999-07-01 # and #2002-07-01#
      

  6.   

    sql = "select *  from table where fDate between #" & 起始日期 & "#" &" and  & "#" & 终止日期& "#"。老是提示:缺少语句结束~~~数据库为ACCESS2000
      

  7.   

    sql = "select *  from table where fDate between #" & 起始日期 & "# and #" & 终止日期 & "#"
    你最好把日期格式 成format(日期,"yyyy-mm-dd")
    你再试试看,OK
      

  8.   

    例:select * from table where fDate between '1999-7-1' and '2002-7-1'rsUser.Open "SELECT ID,发报社号,发报社名,收报社号,收报社名,金额,收款社名称,付款单位名称,编报日期,收发状态值 FROM [" & CStr(WorkDate) & "] where 编报日期 between '99-6-1' and '02-7-1'"提示数据类型不匹配~~~~
      

  9.   

    sql = "select *  from table where fDate between #" & 起始日期 & "# and #" & 终止日期 & "#"
    你最好把日期格式 成format(日期,"yyyy-mm-dd")
    你再试试看,OK
    rsUser.Open "select *  from [" & CStr(WorkDate) & "] where 编报日期 between #" & "99-6-1" & "# and #" & "02-6-1" & "#"成功~~~;D
      

  10.   

    例:select * from table where fDate between '1999-7-1' and '2002-7-1'
    rsUser.Open "SELECT ID,发报社号,发报社名,收报社号,收报社名,金额,收款社名称,付款单位名称,编报日期,收发状态值 FROM [" & CStr(WorkDate) & "] where 编报日期 between '99-6-1' and '02-7-1'"提示数据类型不匹配~~~~
    ----------------------------------------
    你的fdate 是不是日期格式?是的话直接
    select * from table where fdate>date1 and fdate,date2