Hi
i have month and year like
int lastpaidyear = Convert.ToInt32(lastpaidmonth.Rows[0][1].ToString()); ex:8
int lastpaismonth = Convert.ToInt32(lastpaidmonth.Rows[0][2].ToString());ex:2012
and
int selectmonth = Convert.ToInt32( ddlmonth.SelectedValue.ToString());ex:10
int selectyear = Convert.ToInt32( ddlyear.SelectedValue.ToString());ex:2015
now i want total month ?
please help me
2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.

Jean-Claude ColettePosted Nov 3, 2015, 9:39 AM
DateTime second = new DateTime(2015, 10, 21);
DateTime earlierDate = (first > second) ? second.Date : first.Date;
DateTime laterDate = (first > second) ? first.Date : second.Date;
number_month = (number_month < 0) ? 0 : number_month;
//default rounding of the number of plain month completely included between the 2 dates
int remaining_months = 1;
while (earlierDate.AddMonths(remaining_months) <= laterDate)
{
remaining_months++;
}
Francis SusaimichaelPosted Nov 3, 2015, 8:32 AM