473,549 Members | 5,196 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
2 5986

<gi***@gmx.de > wrote in message news:ej******** ******@tk2msftn gp13.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******** ******@tk2msftn gp13.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
11993
by: Shahid Juma | last post by:
Hi, I am trying to figure out a way to get the week number of the current week. I know this is relatively easy using the calendar year (starting from January to now). However, I want to do it so I start in October on the first monday of the month, so today's date would be the 10th week. Any ideas? Shahid
7
15138
by: Shuffs | last post by:
Could someone, anyone please tell me what I need to amend, to get this function to take Sunday as the first day of the week? I amended the Weekday parts to vbSunday (in my code, not the code attached), yet when I ran it for 28/09/2003 (UK date format) it returned Week 39. I would have expected it to return Week 40. However, I'm really stuck...
4
2317
by: A.G. | last post by:
In our company we store employee hours by week number. We have a table called Time which has a unique id of TimeID and then other fields such as date, weeknumber, monday, tuesday, wednesday, etc... The problem is that at the end of the year when the week number goes back to 1, it begins to override the old data. We want to keep the old...
2
1089
by: | last post by:
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();
2
34334
by: Rustan | last post by:
Hi Im using GregorianCalendar to find out the current years week numbers. When the user chooses a week number in a dropdown i want to show that week in a table with the corresponding dates. For example : the user choses week43 (this week) so somehow i must calculate what date is startdate that week (monday 18th). How do i do this with c# ?...
1
2876
by: Martin Emanuelsson | last post by:
Hello, Knowing year and weeknumber of this year, I'm looking for some way to get the date of the first and last day of that particular week. Does anyone have an idea about how to do this? Best regards Martin
10
2737
by: purkka | last post by:
Hi I did not find any solution from Internet how to do it. There is a lot of samples how to retrieve day of the week, but not number of the week. With rgds MP
3
2609
by: sbaird | last post by:
Aloha from Hawaii, I'm beating my head on the wall here. I have a recruiting contact managment database I'm trying to create. Managers (there ar 14 of them) have to make a certain number of recruiting calls per week, and so many of them have to result in at least an appointment. However, the "week" is Wednesday, 12:01pm to the following...
1
2598
by: peetersb | last post by:
Hi, 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);
3
5826
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, is there a way if you are given a Year and a Week an easy way to go back say 26 weeks ago from given year/week. for example, given: 2008/16 26 weeks prior is: 2007/43 thanks,
0
7455
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7723
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7962
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7814
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5373
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5092
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3486
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1063
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.