select * from tableName DATEPART(WEEK,ColumnName,GETDATE()) = 0
这样查返回的是上周日到本周六的
select * from TableName where CONVERT(varchar,ColumnName,23) >= CONVERT(varchar, DATEADD(dd,-(datediff(dd,'2000-01-03',GETDATE()) % 7),GETDATE()),23)
这样查到的就是本周一到本周日的数据了
2024-02-15 14:57:48
select * from tableName DATEPART(WEEK,ColumnName,GETDATE()) = 0
这样查返回的是上周日到本周六的
select * from TableName where CONVERT(varchar,ColumnName,23) >= CONVERT(varchar, DATEADD(dd,-(datediff(dd,'2000-01-03',GETDATE()) % 7),GETDATE()),23)
这样查到的就是本周一到本周日的数据了