467,925 Members | 1,825 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,925 developers. It's quick & easy.

How to get week span with weekNumber and Year

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
Nov 16 '05 #1
  • viewed: 5658
Share:
2 Replies

<gi***@gmx.de> wrote in message news:ej**************@tk2msftngp13.phx.gbl...
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
Nov 16 '05 #2

<gi***@gmx.de> wrote in message news:ej**************@tk2msftngp13.phx.gbl...
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
Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Shahid Juma | last post: by
7 posts views Thread by Shuffs | last post: by
4 posts views Thread by A.G. | last post: by
2 posts views Thread by Rustan | last post: by
1 post views Thread by Martin Emanuelsson | last post: by
10 posts views Thread by purkka | last post: by
3 posts views Thread by sbaird | last post: by
3 posts views Thread by =?Utf-8?B?cm9kY2hhcg==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.