15,850,214 members
See more:
hi friends,

I am using gridview in that I have one bound field and 3 textbox template fields like this
```------------------------------------------------------------- ---------
phase      Duration(weeks)    SrartDate         EndDate

-----------------------------------------------------------------------```

out side of gridview I have field: working days in a week:
ex: 5 0r 6

If I enter 1 or 1.5 week in Duration textbox , start Date : 12-05-2017 and if total working days in a week: 5 based on this values remove sturdays and sundays and find and display
End Date in gridview.

if working days in a week 6 days remove only sundays and find EndDate and display it in gridview.

Example:
If we Consider duration as 1 week,Working days in a week 6

then after 12-05-2017 then remove sunday date from calculation and the final End Date should print

20-05-2017

how to achive this??

What I have tried:

I tried using Adddays Method to given date
Posted
Updated 5-May-17 3:36am
v2
Richard MacCutchan 5-May-17 7:29am
So what is the problem?
prasanna204 5-May-17 7:31am
how to get the end date based on mentioned scenarios?I need code help
Richard MacCutchan 5-May-17 7:49am
Add the number of days to the start date.
[no name] 5-May-17 7:33am
prasanna204 5-May-17 8:08am
Duration(weeks)=1;nofofworkingdays(in a week)=5;
Datetime Dt=convert.Todatedime(txtStartDate.Text);
how to exclude saturdays and sundays if any caluculate based on nofofworking days

## Solution 1

Add the number of days and check the week day afterwards (add one or two days for Sunday and Saturday):
C#
```// Add number of days
// Choose Monday if end date is Sunday
if (dt.DayOfWeek == DayOfWeek.Sunday)
// Choose Monday if end date is Saturday and Saturday is not a working day
else if (workingDays < 6 && dt.DayOfWeek == DayOfWeek.Saturday)

Maciej Los 8-May-17 1:46am
5ed!

Top Experts
Last 24hrsThis month
 k5054 60 Richard MacCutchan 45 Dave Kreskowiak 33 OriginalGriff 20 Sandeep Mewara 10
 k5054 60 Richard MacCutchan 55 Dave Kreskowiak 43 OriginalGriff 40 Richard Deeming 40

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900