tags:

views:

440

answers:

2

Hi Guys,

I have 2 dropdowns 1 with weeknumbers 1 with years. I want to extract the date range from this data.

So:

Weeknumber 13 year 2009 would give:

monday 23 march 2009 tuesday 24 march 2009 ...

VB.Net preferred but C# sollution is also ok.

Edit: Ok I guess I should have mentioned this is for European dates.

+3  A: 
CultureInfo curCulture = CultureInfo.CurrentCulture;

DateTime targetDate = curCulture.Calendar.AddWeeks(new DateTime([year], 1, 1), [Week]);

DayOfWeek targetWeekDay =
    curCulture.Calendar.GetDayOfWeek(targetDate);

DateTime targetBeginningOfWeek = targetDate.AddDays(-1*Convert.ToInt16(targetWeekDay));

targetBeginningOfWeek will contain first day of that week, add 7 days and get rest of day in that week

Brijesh Mishra
Earlier one was incomplete updated one should be helpful
Brijesh Mishra
This worked great, thanks!
mc2thaH
A: 
var date = DateTime.MinValue + 2009.Years() + 13.Weeks();

by using Fluent DateTime project on Codeplex.

Alex