//当年开始日期、结束日期
DateTime currentDate = DateTime.Now.Date;
DateTime yearStart = DateTime.Parse($"{currentDate.Year}-1-1");//开始日期
DateTime yearEnd = yearStart.AddYears(1).AddDays(-1).AddSeconds(-1);
int monthdays = System.Threading.Thread.CurrentThread.CurrentUICulture.Calendar.GetDaysInMonth(currentDate.Year, 12);//月天数
//当月开始日期、结束日期
DateTime monthStart = currentDate.AddDays(1 - currentDate.Day).Date;
DateTime monthEnd = currentDate.AddDays(1 - currentDate.Day).Date.AddMonths(1).AddSeconds(-1);
//上个月开始日期、结束日期
DateTime lastMonthStart = currentDate.AddMonths(-1).Date.AddDays(1 - currentDate.Day);
DateTime lastMonthEnd = DateTime.Parse(currentDate.AddDays(1 - currentDate.Day).ToShortDateString()).AddSeconds(-1);