How to compute end date given the start date?
-
A project in .NET 2.0 C#. I have used the calendar to let user select the start date. However I do not know how to calculate the end date if the duration is 3 months after clicking the submit button. The end date will be displayed at the lblEndDate.
public DateTime strEnd; protected void Calendar1_SelectionChanged(object sender, EventArgs e) { txtStartDate.Text = Calendar1.SelectedDate.ToString("dd MMM yyyy"); } protected void btnStart_Click(object sender, EventArgs e) { //strEnd = txtStartDate.Text.ToString(); //lblEndDate.Text = strEnd.AddDays(90); }
thanks in advance. Much appreciated.
-
A project in .NET 2.0 C#. I have used the calendar to let user select the start date. However I do not know how to calculate the end date if the duration is 3 months after clicking the submit button. The end date will be displayed at the lblEndDate.
public DateTime strEnd; protected void Calendar1_SelectionChanged(object sender, EventArgs e) { txtStartDate.Text = Calendar1.SelectedDate.ToString("dd MMM yyyy"); } protected void btnStart_Click(object sender, EventArgs e) { //strEnd = txtStartDate.Text.ToString(); //lblEndDate.Text = strEnd.AddDays(90); }
thanks in advance. Much appreciated.
-
A project in .NET 2.0 C#. I have used the calendar to let user select the start date. However I do not know how to calculate the end date if the duration is 3 months after clicking the submit button. The end date will be displayed at the lblEndDate.
public DateTime strEnd; protected void Calendar1_SelectionChanged(object sender, EventArgs e) { txtStartDate.Text = Calendar1.SelectedDate.ToString("dd MMM yyyy"); } protected void btnStart_Click(object sender, EventArgs e) { //strEnd = txtStartDate.Text.ToString(); //lblEndDate.Text = strEnd.AddDays(90); }
thanks in advance. Much appreciated.
-
Inspite of using adddays you can use addmonths which requires no. of monts as a parameter.
Best Regards, Apurva Kaushal
Thanks you ring something to me. I still insist on using days. And it can work. Thanks Apurva Kaushal.
lblEndDate.Text = Calendar1.SelectedDate.AddDays(81).ToString("dd MMM yyyy"); // subtract 3 days because I want to end on a friday
Loving Code Project -
Oh my. I suddenly have the solution before you submit the answer. Thanks Nav for your effort replying. :rose: lblEndDate.Text = Calendar1.SelectedDate.AddDays(81).ToString("dd MMM yyyy"); // subtract mondays,sundays,saturdays Thanks NAV!!!!!!!!!!!
-
Thanks you ring something to me. I still insist on using days. And it can work. Thanks Apurva Kaushal.
lblEndDate.Text = Calendar1.SelectedDate.AddDays(81).ToString("dd MMM yyyy"); // subtract 3 days because I want to end on a friday
Loving Code Project