hi in this post i will show how to calculate days,months and years between two date in asp.net,c#(code-behind):
Below is the code for this:
public void calcDayMonthYear()
{
DateTime dayStart;
DateTime dateEnd;
dayStart = Convert.ToDateTime(frmdate.Text);
dateEnd = Convert.ToDateTime(todate.Text);
TimeSpan ts = dateEnd - dayStart;
double Years = Convert.ToDouble(ts.TotalDays) / 365;
double Months = Years * 12;
double Days = Convert.ToDouble(ts.TotalDays);
}
Below is the code for this:
public void calcDayMonthYear()
{
DateTime dayStart;
DateTime dateEnd;
dayStart = Convert.ToDateTime(frmdate.Text);
dateEnd = Convert.ToDateTime(todate.Text);
TimeSpan ts = dateEnd - dayStart;
double Years = Convert.ToDouble(ts.TotalDays) / 365;
double Months = Years * 12;
double Days = Convert.ToDouble(ts.TotalDays);
}
devil
ReplyDelete