Bevan
Bevan

Reputation: 584

How do I get the start date for the current week in SQL Server 2008?

using: SQL Server 2008r2 via: aspx HTML page

I need to find the start date for the current week. It does not matter if it gives me Sunday's date or Monday's date, but I need to be able to find all transactions this week, for example.

Also, if someone can point me to a page that explains all the Date functions in SQL2008 that would be splendid too!

I searched around and found not much that was applicable (either I didn't search with the right keywords or there literally is no-one who has asked this before!)

Upvotes: 2

Views: 79

Answers (1)

killQuotes
killQuotes

Reputation: 178

A combination of dateadd and datediff will accomplish this.

select dateadd(wk, datediff(wk, 0, getdate()), 0)

Note that wk is the abbreviation for the week datepart parameter in dateadd.

This MSDN page clearly and comprehensively explains the Date (and Time) methods in SQL 2008 R2.

Upvotes: 3

Related Questions