您现在的位置: Gufang > 博客 > 学无止境 > 正文
ASP sql 查询 当天 当月 上月 记录

当天

SQL Server:

select top 10 * from test where day(AddTime)=day(getdate()) and year(AddTime)=year(getdate())
select * from test  where datediff(d,AddTime,getdate())=0

Access:

select top 10 * from test where day(AddTime)=day(Now()) and year(AddTime)=year(Now())

test是表,dateandtime是日期/时间字段

上月

select * from 表名 where datediff(month,日期字段,getdate())=1

发表评论(0)
姓名 *
电子邮件
QQ
评论内容 *
验证问题 * 江苏省的省会是哪个城市?请填写正确答案
验证码 * 图片看不清?点击重新得到验证码