表名:A
id content ptime
1 123 2004-8-17 10:20:53
2 456 2004-8-18 3:34:55
....
200 673 2006-6-7 10:20:53我现在要按照时间提取今日的数据,最近一周的数据和最近一月内的数据我会尽快揭贴
id content ptime
1 123 2004-8-17 10:20:53
2 456 2004-8-18 3:34:55
....
200 673 2006-6-7 10:20:53我现在要按照时间提取今日的数据,最近一周的数据和最近一月内的数据我会尽快揭贴
--今日的数据select * from A where datediff(day,ptime,getdate())=0
Select * From A Where DateDiff(wk,ptime,GetDate())=0
Select * From A Where DateDiff(mm,ptime,GetDate())=0
Select * From A Where DateDiff(dd,ptime,GetDate())=0
--本周
Select * From A Where DateDiff(wk,ptime,GetDate())=0
--本月
Select * From A Where DateDiff(mm,ptime,GetDate())=0