-3

I want to display all the dates between two dates with year.

Eg: FromDate = 2012-01-01  ToDate=2013-05-01

Output should be : 
    January 2012
    February 2012
    March 2012
    April 2012
    ...
    May 2013

Thanks for any valuable inputs.

MAF
  • 27
  • 9

1 Answers1

2
' Start from getting date with year and month from FromDate and 1 as a day '
Dim RealFromDate = new DateTime(FromDate.Year, FromDate.Month, 1)

While RealFromDate <= EndDate
    Console.WriteLine(RealFromDate.ToString("yyyy MMM")
    RealFromDate = RealFromDate.AddMonths(1)
End While
MarcinJuraszek
  • 124,003
  • 15
  • 196
  • 263