How to find the first day of next month,if the current month is december

前端 未结 10 1933
独厮守ぢ
独厮守ぢ 2021-01-01 11:03

I\'m using the following query to get the next month.

int theMonth = ((System.DateTime)periodStartDate).Month+1;

But if the periodstartDate

10条回答
  •  离开以前
    2021-01-01 11:41

    If you call AddMonths(1) then .NET will automatically roll the date into the next year.

    periodStartDate.AddMonths(1).Month;
    

提交回复
热议问题