Friday, February 3, 2012

Get Month and Year between two dates in C#.NET

This snippet of code shows how to get Month and Year between two dates. The code below return an array of ListItems.

public ArrayList GetMonthYear(DateTime dtStart, DateTime dtEnd)
{

ArrayList monthList = new ArrayList();
for (DateTime dt = dtStart; dt <= dtEnd; dt = dt.AddMonths(1))
{
monthList.Add(
new ListItem(dt.ToString("MMMM yyyy"), dt.ToString("yyyy")));
}

return monthList;
}

Sample Output:

June 2010
July 2010
August 2010
September 2010
October 2010
November 2010
December 2010
January 2011
February 2011

Codeigniter Shield Authorization

Codeigniter Shield Authorization CodeIgniter Shield is the official authentication and authorization framework for CodeIgniter 4. It provide...