日期:2014-05-17 浏览次数:20834 次
<% n = Trim(Request("n")) If n = "" Then n = 0 End If n = CInt(n) cd = DateAdd("ww",n , Date()) w = Weekday(cd, 2) fd = DateAdd("d", 1-w, cd) For i = 0 To 6 dt = DateAdd("d", i , fd) response.Write fmtDate(dt) & "<br>" Next Function fmtDate(dt) Dim y, m, d y = Year(dt) m = "0" & Month(dt) d = "0" & Day(dt) m = Right(m, 2) d = Right(d, 2) fmtDate = y & "-" & m & "-" & d End Function %> <input type="button" value="上一周" onclick="location.href='?n=<%=n-1%>'"> <input type="button" value="下一周" onclick="location.href='?n=<%=n+1%>'">
------解决方案--------------------
本周:DateDiff("ww", Now,theDate)=0
上一周:DateDiff("ww", Now,theDate)=-1
下一周:DateDiff("ww", Now,theDate)=1
就这么简单
如果是ACCESS数据库就用:
本周:selsec * from 表 where DateDiff('ww', Now,时间字段)=0
上一周:selsec * from 表 where DateDiff('ww', Now,时间字段)=-1
下一周:selsec * from 表 where DateDiff('ww', Now,时间字段)=1
mssql数据库:
本周:selsec * from 表 where DateDiff(ww,getdate(),时间字段)=0
上一周:selsec * from 表 where DateDiff(ww,getdate(),时间字段)=-1
下一周:selsec * from 表 where DateDiff(ww,getdate(),时间字段)=1