sql-server如何返回一个星期内开户的卡号
来源:百度知道 编辑:UC知道 时间:2024/05/23 20:15:14
table1
cardID openDate
--------------------------
123 2007-12-1
234 2007-12-2
345 2007-11-15
cardID openDate
--------------------------
123 2007-12-1
234 2007-12-2
345 2007-11-15
以下语句返回本周内开户的卡号,而不是最近7天内开户的卡号:
select cardID from table1 where datediff("ww",openDate,now())=0
以下语句返回最近7天内开户的卡号:
select cardID from table1 where datediff("d",openDate,now())<=7
select * from table1 where opendate.....
select cardID from table1 where openDate between getdate()-7 and getdate();