How do I compare against the current week using SQL Server?

sql, sql-server, t-sql

Solution

You could convert your date to a week number and compare this to the week number from the current date. Likewise, you'll need to compare the year as well, so that you don't get last year's weeks.

WHERE DATEPART(wk, [Order].SubmittedDate) = DATEPART(wk, GETDATE())
AND DATEPART(yy, [Order].SubmittedDate) = DATEPART(yy, GETDATE())

Problem

How do I compare an SQL Server date column against the current week? For instance: ``` WHERE [Order].SubmittedDate = *THIS WEEK* ```

Original source