By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,704 Members | 1,475 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,704 IT Pros & Developers. It's quick & easy.

Firt day and last day of week (weeknumber as parameter ans year)

P: n/a

I want ot make functions like this:

int getFirtDayOfWeek(int weeknumber, int year);
int getLastDayOfWeek(int weeknumber, int year);

Firts I calculate the count of weeks like this:

DateTime lastDay = new DateTime(DateTime.Now.Year, 12, 31);
DayOfWeek dayOfWeek = lastDay.DayOfWeek;
CultureInfo myCI = new CultureInfo("nl-BE");
Calendar myCal = myCI.Calendar;
CalendarWeekRule myCWR =
DayOfWeek myFirstDOW = myCI.DateTimeFormat.FirstDayOfWeek;
int weeks = myCal.GetWeekOfYear(lastDay, myCWR,

So for this year there are 53 weeks.
Now I want the firts day of week 2 for example ( = 7)
and the last day of week 2 (= 13)
How can I do that?
Feb 1 '08 #1
Share this Question
Share on Google+
1 Reply

P: n/a

This is my (untested) guess:

int getFirtDayOfWeek(int weeknumber, int year) {
System.DateTime date = new DateTime(year, 1, 1);
date.AddDays(7 * weeknumber);
return date.Day;
int getLastDayOfWeek(int weeknumber, int year){
System.DateTime date = new DateTime(year, 1, 1);
date.AddDays((7 * weeknumber) + 7);
return date.Day;

I guess you'd need to add checks for the last week of the year...

Feb 1 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.