janhartmann
janhartmann

Reputation: 15003

Getting dates based on week number

I have some rows in my database that contains some dates.

I need to select all dates based on a weeknumber, how is this possible?

Upvotes: 1

Views: 293

Answers (2)

Salil
Salil

Reputation: 47542

select date from table_name where DATE_FORMAT(date, "%U-%Y")="11-2010"

where 11 is week number

and 2010 is year

Upvotes: 0

David M
David M

Reputation: 72930

The T-SQL DATEPART function will take week (abbreviated form wk) as its first parameter. This will do what you want. Reference here:

http://msdn.microsoft.com/en-us/library/ms174420.aspx

Upvotes: 2

Related Questions