/// <summary> /// 取得某月的第一天 /// </summary> /// <param name="datetime">要取得月份第一天的时间</param> /// <returns></returns> private DateTime FirstDayOfMonthDateTime datetime) { return datetime.AddDays1 - datetime.Day); } //// <summary> /// 取得某月的最后一天 /// </summary> /// <param name="datetime">要取得月份最后一天的时间</param> /// <returns></returns> private DateTime LastDayOfMonthDateTime datetime) { return datetime.AddDays1 - datetime.Day).AddMonths1).AddDays-1); } //// <summary> /// 取得上个月第一天 /// </summary> /// <param name="datetime">要取得上个月第一天的当前时间</param> /// <returns></returns> private DateTime FirstDayOfPreviousMonthDateTime datetime) { return datetime.AddDays1 - datetime.Day).AddMonths-1); } //// <summary> /// 取得上个月的最后一天 /// </summary> /// <param name="datetime">要取得上个月最后一天的当前时间</param> /// <returns></returns> private DateTime LastDayOfPrdviousMonthDateTime datetime) { return datetime.AddDays1 - datetime.Day).AddDays-1); }
为了方便我后面找,就发布到自己下面了
转自https://www.cnblogs.com/junjie94wan/archive/2012/08/31/2664947.html