How to get week span with weekNumber and Year

G

Guest

Hi!!

know someone how to get a week span with week number and year?

something like hi:

public static DateTime[] GetWeekSpan(int weekNumber, int year)
{
DateTime weekStartDate = new DateTime();
DateTime weekEndDate = new DateTime();

//do something to find the sweek span!!!!

DateTime[] currentWeekSpan = new DateTime[2];

currentWeekSpan[0] = weekStartDate;
currentWeekSpan[1] = weekEndDate;

return currentWeekSpan;
}

any ideas???


regards,

gicio
 
H

Hans Kesting

Hi!!

know someone how to get a week span with week number and year?

something like hi:

public static DateTime[] GetWeekSpan(int weekNumber, int year)
{
DateTime weekStartDate = new DateTime();
DateTime weekEndDate = new DateTime();

//do something to find the sweek span!!!!

DateTime[] currentWeekSpan = new DateTime[2];

currentWeekSpan[0] = weekStartDate;
currentWeekSpan[1] = weekEndDate;

return currentWeekSpan;
}

any ideas???


regards,

gicio

Basically you need to find the startdate of a particular week. This depends
on the particular locale (for instance: in the Netherlands week 1 of 2004 starts
at monday, december 29, 2003 and week 1 of 2005 is jan 3, 2005)
Maybe you could try the following:
- find the startday of week 1 of the year
- first day is sunday or monday (or other?)
- week 1 could be "includes jan 1", "first full week", "at least 4 days", ...
- add the number of weeks (minus one, as the numbering starts at 1)

Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top