/// <Summary>
/// Obtain the month between two time periods
/// </Summary>
/// <Param name = "startTime"> Start month </param>
/// <Param name = "endTime"> end month </param>
/// <Returns> month string </returns>
Public static string DateFiledMonths (string startTime, string endTime)
{
Try
{
Int index = 0;
String filed = string. Empty;
DateTime c1 = Convert. ToDateTime (Convert. ToDateTime (startTime). ToString ("yyyy-MM "));
DateTime c2 = Convert. ToDateTime (Convert. ToDateTime (endTime). ToString ("yyyy-MM "));
If (c1> c2)
{
DateTime tmp = c1;
C1 = c2;
C2 = tmp;
}
While (c2> = c1)
{
Index ++;
If (index> 12) // determine whether the value is greater than 12 months. if the value is greater than 12 months, the system jumps out of www.2cto.com.
Break;
Filed + = c1.ToString ("yyyy-MM") + "| ";
C1 = c1.AddMonths (1 );
}
Return filed. TrimEnd ('| ');
}
Catch {return null ;}
}
From Zhu jintuo's column