我的数据库是ACCESS,其中有一个字段是“上传日期”的字段,现在我要列所近一周的上传内容这个SQL语句应该怎么写啊,asp.net(C#)
其实我的意思是就是“select * from 表 where 当前时间-上传日期<=7” 的一个SQL语句应该怎么写啊?数据是ACCESS,求各位了,小弟急?

解决方案 »

  1.   

    select * from 表 where datediff(d,@当前时间,@上传日期)<=7
      

  2.   

    select * from 表 where date()-上传日期<=7
      

  3.   

    select * from 表 where datediff(d,date(),上传日期)<=7
      

  4.   

    1、DataTime tmpDate=DateTime.Now-7
    2、string cmdSelect=select * from 表 where 上传日期>='"+tmpDate.ToShortDateString()+"'";
      

  5.   

    datediff
    楼主看下SQL帮助就明白。
      

  6.   

    楼主,打开SQLSERVER ,然后按F1,然后在索引上找日期
      

  7.   

    select * from 表 where datediff(d,date(),上传日期)<=30 //近一月
    select * from 表 where datediff(d,date(),上传日期)<=365 //近一年
      

  8.   

    ACCESS中
    select * from 表 where datediff('d',date(),上传日期)<=7
    单引号中的d表示day,如果要月,可以用'm',年是'yyyy'
    或者用select * from 表 where dateadd('d',7,上传日期)>=date()
    用datediff可以做的,dateadd也可以做。