Quantcast
Viewing all articles
Browse latest Browse all 46

Answer by reza akhlaghi for Difference in months between two dates

I wrote a function to accomplish this, because the others ways weren't working for me.

public string getEndDate (DateTime startDate,decimal monthCount){    int y = startDate.Year;    int m = startDate.Month;    for (decimal  i = monthCount; i > 1; i--)    {        m++;        if (m == 12)        { y++;            m = 1;        }    }    return string.Format("{0}-{1}-{2}", y.ToString(), m.ToString(), startDate.Day.ToString());}

Viewing all articles
Browse latest Browse all 46

Trending Articles