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

前端 未结 10 2026
独厮守ぢ
独厮守ぢ 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 12:02

    after you compute theMonth, check whether it equals to 13 (the month after December) and replace the value with 1:

    theMonth = theMonth==13 ? 1 : theMonth;
    

提交回复
热议问题