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

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

    I think you can get it in this fashion

    DateTime dt = new DateTime(2011,12,2);
    DateTime dayone = new DateTime(dt.AddMonths(1).Year, dt.AddMonths(1).Month, 1);
    

    Now you have a proper DateTime object to the first of the next month, do as you please with it

提交回复
热议问题