In an ASP.NET MVC application, I get the date from the database in this way:
public class MonthController : ApiController
{
public List<Month> monthContainer;
public List<Month> getMonth()
{
DataContext dataContext = new DataContext();
monthContainer = (from d in dataContext.Duties
select new Month()
{
MonthDate = d.Date
}).ToList();
return monthContainer;
}
In the answer comes a date in this format:
{
"MonthDate": "2015-10-01T00:00:00"
},
{
"MonthDate": "2015-10-02T00:00:00"
}
And so it goes every day of the month MonthDate until a certain year. How can I withdraw only months in this format without doubles? How to make a change in the controller? I want to get this format:
"MonthDate": "2015-10"
"MonthDate": "2015-11"
"MonthDate": "2015-12"
"MonthDate": "2016-01"
... "MonthDate": "2019-12"