Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to compute end date given the start date?

How to compute end date given the start date?

Scheduled Pinned Locked Moved ASP.NET
csharptutorialquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    blurMember
    wrote on last edited by
    #1

    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.

    _ M 2 Replies Last reply
    0
    • B blurMember

      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.

      _ Offline
      _ Offline
      _AK_
      wrote on last edited by
      #2

      Inspite of using adddays you can use addmonths which requires no. of monts as a parameter.

      Best Regards, Apurva Kaushal

      B 1 Reply Last reply
      0
      • B blurMember

        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.

        M Offline
        M Offline
        mnaveed
        wrote on last edited by
        #3

        lblEndDate.Text = Calendar1.SelectedDate.AddMonths(3).ToString("dd MMM yyyy");

        Nav.

        B 1 Reply Last reply
        0
        • _ _AK_

          Inspite of using adddays you can use addmonths which requires no. of monts as a parameter.

          Best Regards, Apurva Kaushal

          B Offline
          B Offline
          blurMember
          wrote on last edited by
          #4

          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

          _ 1 Reply Last reply
          0
          • M mnaveed

            lblEndDate.Text = Calendar1.SelectedDate.AddMonths(3).ToString("dd MMM yyyy");

            Nav.

            B Offline
            B Offline
            blurMember
            wrote on last edited by
            #5

            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!!!!!!!!!!!

            1 Reply Last reply
            0
            • B blurMember

              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

              _ Offline
              _ Offline
              _AK_
              wrote on last edited by
              #6

              if you requirement is not fixed to the number of months(an integer) then your choice is obvious of AddDays. :)

              Best Regards, Apurva Kaushal

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups