Friday, May 1, 2015

asp.net Get Date Difference In Days

   public static Int32 GetDateDiffInDays(string sourceDate, string targetDate)
        {
            TimeSpan spanPassed;
            DateTime date1 = System.Convert.ToDateTime(sourceDate);
            DateTime date2 = System.Convert.ToDateTime(targetDate);
            spanPassed = date1.Subtract(date2);

            return spanPassed.Days;
        }

No comments:

Post a Comment