1 /// <summary> 2 /// 取得当前年的第一天 3 /// </summary> 4 /// <param name="datetime">要取得月份第一天的时间</param> 5 /// <returns></returns> 6 private DateTime FirstDayOfYear(DateTime datetime) 7 { 8 DateTime AssemblDate = Convert.ToDateTime(datetime.Year + "-" + "01" + "-" + "01"); // 组装当前指定月份 9 return AssemblDate; // 返回指定当前月份的第一天 10 } 11 12 /// <summary> 13 /// 取得当前年的最后天 14 /// </summary> 15 /// <param name="datetime">要取得月份第一天的时间</param> 16 /// <returns></returns> 17 private DateTime LastDayOfYear(DateTime datetime) 18 { 19 DateTime AssemblDate = Convert.ToDateTime(datetime.AddYears(1).Year + "-" + "01" + "-" + "01"); // 组装当前指定月份 20 return AssemblDate.AddDays(-1); 21 }