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

前端 未结 10 2052
独厮守ぢ
独厮守ぢ 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:03

        DateTime nextMonthStartDate= DateTime.Parse(startdate.Year + "-" + startdate.AddMonths(1).Month + "-01");
    

    This will work in leap year or non leap year. In the above converting strings to date time with static date 1 coz always taking start of the month. Hope it is useful

提交回复
热议问题