using System;
public class MainClass{
/// <summary>
/// Gets the days between.
/// </summary>
/// <param name="first">The first.</param>
/// <param name="last">The last.</param>
/// <param name="inclusive">if set to <c>true</c> [inclusive].</param>
/// <returns></returns>
public static int GetDaysBetween(DateTime first, DateTime last, bool inclusive)
{
TimeSpan span = last - first;
return inclusive ? span.Days + 1 : span.Days;
}
/// <summary>
/// Gets the months between.
/// </summary>
/// <param name="first">The first.</param>
/// <param name="last">The last.</param>
/// <param name="inclusive">if set to <c>true</c> [inclusive].</param>
/// <returns></returns>
public static int GetMonthsBetween(DateTime first, DateTime last, bool inclusive)
{
int result = GetDaysBetween(first, last, true) / 30;
return inclusive ? result + 1 : result;
}
}
|