Tuesday, July 15, 2014

Add Month To any Given Date

using System.Globalization;

protected void DropEMISchedule_SelectedIndexChanged(object sender, EventArgs e)

{

DateTime dt;

int calcy = Convert.ToInt32(DropEMISchedule.SelectedValue) * Convert.ToInt32(txttenure.Text);

if (DateTime.TryParseExact(txtEMIStartDate.Text, "dd/MM/yyyy",new CultureInfo("en-US"),  System.Globalization.DateTimeStyles.None, out dt))

   {

     TextBoxend.Text = "";

     DateTime dtshow = dt.Date.AddMonths(calcy);
  
     TextBoxend.Text = (dtshow).ToString("dd/MM/yyyy");

    }
 }