代码修改表中的两个字段,
sql = "update StoreIn set ProNum=ProNum+20, b = b + 30 where ...."
想实现只修改当天的记录,where条件怎么写?  字段dates(日期)
表结构:ProNum  b      dates
  .     .       .
  .     .       .
  .     .       .
  20    3    2006-6-7
  24    6    2006-6-8
  35    12   2006-6-9
   .     .     .

解决方案 »

  1.   

    当天什么概念?如果是0点到24点的话
    sql = ".... where dates between'" & CStr(Date) & "' and '" & CStr(Date+1) & "'"
      

  2.   

    sql = ".... where dates between '" & CStr(Date) & "' and '" & CStr(Date+1) & "'"
      

  3.   

    sql = "update StoreIn set ProNum=ProNum+20, b = b + 30 where CONVERT(char(10),Dates,120)= '" & Format(Date,"YYYY-MM-DD") & "'"
      

  4.   

    3楼的要对每条数据进行运算,效率比较低
    还是2楼的我的方式比较好,直接给出一个范围比如
    dates between '2006-06-09' and '2006-06-10'
    因为数据库的时间字段都是包含时间的,实际是
    dates字段2006-06-09 00:00:00 到 2006-06-10 00:00:00的数据
    也就是所有dates为2006-06-09 xx:xx:xx的数据