473,513 Members | 2,448 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

adding days to a date, bypass weekends

Hi

I have a date in UK Format (dd/mm/yyyy). I want to get a series of days
after that date, but NOT Saturday or Sunday

For example, if the date is 13/12/2004 (next Monday) and I get the next 9
dates, I want to end up with a full list like.. 13, 14, 15, 16, 17, 20, 21,
22, 23, 24 (2wks, mon-fri).

How can I acheive this? (im using C#)

Cheers
Dan
Nov 19 '05 #1
4 4777
Make a DateTime variable, increment it in a loop and check DayOfWeek
property.

Eliyahu

"dhnriverside" <da*@musoswire.com> wrote in message
news:46**********************************@microsof t.com...
Hi

I have a date in UK Format (dd/mm/yyyy). I want to get a series of days
after that date, but NOT Saturday or Sunday

For example, if the date is 13/12/2004 (next Monday) and I get the next 9
dates, I want to end up with a full list like.. 13, 14, 15, 16, 17, 20, 21, 22, 23, 24 (2wks, mon-fri).

How can I acheive this? (im using C#)

Cheers
Dan

Nov 19 '05 #2
"dhnriverside" <da*@musoswire.com> wrote in message
news:46**********************************@microsof t.com...
Hi

I have a date in UK Format (dd/mm/yyyy). I want to get a series of days
after that date, but NOT Saturday or Sunday

For example, if the date is 13/12/2004 (next Monday) and I get the next 9
dates, I want to end up with a full list like.. 13, 14, 15, 16, 17, 20,
21,
22, 23, 24 (2wks, mon-fri).

How can I acheive this? (im using C#)


Did you look at the members of the DateTime structure?

John Saunders
Nov 19 '05 #3
Hi

Have checked out DateTime, and come up with the following code. It's
supposed to increment the dates by a week, and create a string of the dates...

DateTime dates;
dates = DateTime.Parse(txtSessionDate.Text); // txtSessionDate.Text =
15/12/2004
listOfDates = dates.ToShortDateString();
//weeks
for(x=0; x < Convert.ToInt32(txtRecurs.Text); x++)
{
xw = x * 7;
DateTime newdate;
newdate = dates;
newdate.AddDays(xw);
listOfDates += ", " + newdate.ToShortDateString();
}

It creates a string of dates, but the AddDays method doesn't seem to be
doing anything. It compiles, but all the dates in the string are the same?!

Cheers
Dan
"John Saunders" wrote:
"dhnriverside" <da*@musoswire.com> wrote in message
news:46**********************************@microsof t.com...
Hi

I have a date in UK Format (dd/mm/yyyy). I want to get a series of days
after that date, but NOT Saturday or Sunday

For example, if the date is 13/12/2004 (next Monday) and I get the next 9
dates, I want to end up with a full list like.. 13, 14, 15, 16, 17, 20,
21,
22, 23, 24 (2wks, mon-fri).

How can I acheive this? (im using C#)


Did you look at the members of the DateTime structure?

John Saunders

Nov 19 '05 #4
"dhnriverside" <da*@musoswire.com> wrote in message
news:3B**********************************@microsof t.com...
Hi

Have checked out DateTime, and come up with the following code. It's
supposed to increment the dates by a week, and create a string of the
dates...

DateTime dates;
dates = DateTime.Parse(txtSessionDate.Text); // txtSessionDate.Text =
15/12/2004
listOfDates = dates.ToShortDateString();
//weeks
for(x=0; x < Convert.ToInt32(txtRecurs.Text); x++)
{
xw = x * 7;
DateTime newdate;
newdate = dates;
newdate.AddDays(xw);
listOfDates += ", " + newdate.ToShortDateString();
}

It creates a string of dates, but the AddDays method doesn't seem to be
doing anything. It compiles, but all the dates in the string are the
same?!


AddDays is a function:

newdate = dates.AddDays(xw);

John Saunders
Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
23662
by: Anthony Robinson | last post by:
Is anyone aware of a function (system or user defined) that will calculate business days? For instance: I have a column in as table called DATE. I want to be able to add five business days to that...
5
14871
by: BlackFireNova | last post by:
I need to write a report in which one part shows a count of how many total records fall within the working days (Monday - Friday) inside of a (prompted) given date range, in a particular...
2
2068
by: dixie | last post by:
I have a report which is printed daily. It is a list of people. A person can be put on this list for one day, which is easyily achieved from a simple form. My problem is that a person can also...
0
1516
by: kumarkanth | last post by:
My question is how do I manipulate the procedure to calculate cut-off date with in working days and it should skip weekends and holidays? I have holiday table to determine holidays Table Name :...
4
2835
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi, I have a web application that I need to add 3 days to the Now day, but need to make sure that I skip weekends and holidays. For example if Now is friday, 3 days + now should be tuesday,...
7
3211
by: Mike | last post by:
I have a routine that's calculating business days but its not counting the weekend days that are between the start date and end date. If my start date is 9/26/08 and my end date is 10/01/08, I...
5
24525
FishVal
by: FishVal | last post by:
IMHO, the following is not a how-to-do instruction to solve a particular problem but more a concept-proof stuff demonstrating possibilities of SQL. So, let us say the problem is to calculate...
1
1564
by: geraldjr30 | last post by:
hi, i have the following to calculate working days between 2 dates, but i am not getting the right amount. i should be getting 11 instead of 12, because feb 16 2009 was a holiday. can someone...
0
1884
by: geraldjr30 | last post by:
hi, i have the following: <?php echo"test"; //The function returns the no. of business days between two dates and it skips the holidays function...
0
7171
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...
0
7388
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,...
0
7545
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...
0
7539
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...
1
5095
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...
0
4751
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...
0
3240
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3228
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
461
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.