vb.net两个日期之间的月份

时间:2013-11-18 05:03:16

标签: vb.net date between

我想显示两个日期与年份之间的所有日期。

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

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

感谢任何有价值的投入。

1 个答案:

答案 0 :(得分: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