none
add number to date time picker and display result in another date time picker RRS feed

  • Question

  • hi ....

    haw can i add number of month or year to my current date and display it using datetimepicker ....

    ex.

    1- current date = 13/12/2013 i need to add number 1 which present 1 month 

        result date = 13/1/2014 .

    Friday, December 13, 2013 7:38 PM

Answers

  • Is this what you are looking for ?

      string dateNow = DateTime.Now.ToString("dd/MM/yyyy");//or from your other date picker value
                DateTime objDate = DateTime.ParseExact(dateNow, "dd/MM/yyyy", null);
                objDate = objDate.AddMonths(1);//adding one month
                //objDate = objDate.AddYears(1);//adding one year
                this.dateTimePicker1.Value = objDate;
    

    Saturday, December 14, 2013 1:23 AM
  • try this Code

    dateTimePicker2.Value = dateTimePicker1.Value.AddMonths(1);



    Happy Coding, RDRaja

    Saturday, December 14, 2013 9:48 AM

All replies

  • Is this what you are looking for ?

      string dateNow = DateTime.Now.ToString("dd/MM/yyyy");//or from your other date picker value
                DateTime objDate = DateTime.ParseExact(dateNow, "dd/MM/yyyy", null);
                objDate = objDate.AddMonths(1);//adding one month
                //objDate = objDate.AddYears(1);//adding one year
                this.dateTimePicker1.Value = objDate;
    

    Saturday, December 14, 2013 1:23 AM
  • try this Code

    dateTimePicker2.Value = dateTimePicker1.Value.AddMonths(1);



    Happy Coding, RDRaja

    Saturday, December 14, 2013 9:48 AM
  • thanks a lot venkat786  that was very helpful for me ... thanks again .. :)
    Saturday, December 14, 2013 3:18 PM
  • thanks a lot raja  that was very helpful for me ... thanks again .. :)
    Saturday, December 14, 2013 3:19 PM