I have this function which gives me ( for a current date ) – its week num :
so for : DateTime(2009,1,1)
CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(new DateTime(2009,1,1), CalendarWeekRule.FirstDay, DayOfWeek.Sunday).Dump();
answer : 1
and for : DateTime(2009,1,4)
answer : 2

now , I need a function which gives me the startDate && endDate for this values :
so for week #1 -> 1/1/2009 ---> 1/3/2009
so for week #2 -> 1/4/2009 ---> 1/10/2009
Hence : i have a function which gives me the week num for a specified date.
but this week spans from x---> y
I need those x and y.
thanks.
p.s. – i’ve been searching for a func like this , and didn’t find . 🙁
To get the first day in the week, by date:
The last day of the week works the same way:
Royi’s addition ( final) :
extension method which gives you all the details ( week details) from a single date :
p.s. first day of week = sunday.