C# 获取特殊日期
//1.当前时间
DateTime dt = DateTime.Now;
//2.本周周一
DateTime startWeek = dt.AddDays(1 - Convert.ToInt32(dt.DayOfWeek.ToString("d")));
//3.本周周日
DateTime endWeek = startWeek.AddDays(6);
//4.本月月初
DateTime startMonth = dt.AddDays(1 - dt.Day);
//5.本月月末
DateTime endMonth = startMonth.AddMonths(1).AddDays(-1);
endMonth = startMonth.AddDays((dt.AddMonths(1) - dt).Days - 1);
//6.本季度初
DateTime startQuarter = dt.AddMonths(0 - (dt.Month - 1) % 3).AddDays(1 - dt.Day);
//7.本季度末
DateTime endQuarter = startQuarter.AddMonths(3).AddDays(-1);
//8.本年年初
DateTime startYear = new DateTime(dt.Year, 1, 1);
//9.本年年末
DateTime endYear = new DateTime(dt.Year, 12, 31);
//10.上周一
DateTime.Now.AddDays(Convert.ToInt32(1 - Convert.ToInt32(DateTime.Now.DayOfWeek)) - 7);
//11.上周末(星期日)
DateTime.Now.AddDays(Convert.ToInt32(1 - Convert.ToInt32(DateTime.Now.DayOfWeek)) - 7).AddDays(6);
//12.下周一
DateTime.Now.AddDays(Convert.ToInt32(1 - Convert.ToInt32(DateTime.Now.DayOfWeek)) + 7);
//13.下周末
DateTime.Now.AddDays(Convert.ToInt32(1 - Convert.ToInt32(DateTime.Now.DayOfWeek)) + 7).AddDays(6);
//14.本年最后一天
DateTime.Parse(DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + "1").AddMonths(1).AddDays(-1).ToShortDateString();
//15.本月初
DateTime.Now.ToString("yyyy-MM-01");
//16.本月最后一天
DateTime.Parse(DateTime.Now.ToString("yyyy-MM-01")).AddMonths(1).AddDays(-1).ToShortDateString();
//17.上个月第一天
DateTime.Parse(DateTime.Now.ToString("yyyy-MM-01")).AddMonths(-1).ToShortDateString();
//18.上个月最后一天
DateTime.Parse(DateTime.Now.ToString("yyyy-MM-01")).AddDays(-1).ToShortDateString();
//19.下个月第一天
DateTime.Parse(DateTime.Now.ToString("yyyy-MM-01")).AddMonths(1).ToShortDateString();
//20.下下月最后一天
DateTime.Parse(DateTime.Now.ToString("yyyy-MM-01")).AddMonths(2).AddDays(-1).ToShortDateString();
//21.7天后
DateTime.Now.AddDays(7).ToShortDateString();
//22.7天前
DateTime.Now.AddDays(-7).ToShortDateString();
//23.本年度第一天
DateTime.Parse(DateTime.Now.ToString("yyyy-01-01")).ToShortDateString();
//24.本年度最后一天
DateTime.Parse(DateTime.Now.ToString("yyyy-01-01")).AddYears(1).AddDays(-1).ToShortDateString();
//25.上年度第一天,
DateTime.Parse(DateTime.Now.ToString("yyyy-01-01")).AddYears(-1).ToShortDateString();
//26.上年度第最后一天,
DateTime.Parse(DateTime.Now.ToString("yyyy-01-01")).AddDays(-1).ToShortDateString();
//27.下年度第一天
DateTime.Parse(DateTime.Now.ToString("yyyy-01-01")).AddYears(1).ToShortDateString();
//28.下年度最后一天
DateTime.Parse(DateTime.Now.ToString("yyyy-01-01")).AddYears(2).AddDays(-1).ToShortDateString();
//29.本季度第一天;
DateTime.Now.AddMonths(0 - ((DateTime.Now.Month - 1) % 3)).AddDays(1 - DateTime.Now.Day);
//30.本季度的最后一天
DateTime.Parse(DateTime.Now.AddMonths(3 - ((DateTime.Now.Month - 1) % 3)).ToString("yyyy-MM-01")).AddDays(-1).ToShortDateString();
//31.下季度的第一天
DateTime.Now.AddMonths(3 - ((DateTime.Now.Month - 1) % 3)).ToString("yyyy-MM-01");
//32.下季度最后一天
DateTime.Parse(DateTime.Now.AddMonths(6 - ((DateTime.Now.Month - 1) % 3)).ToString("yyyy-MM-01")).AddDays(-1).ToShortDateString();
//33.上季度第一天
DateTime.Now.AddMonths(-3 - ((DateTime.Now.Month - 1) % 3)).AddDays(1 - DateTime.Now.Day);
//34.上季度最后一天
DateTime.Now.AddMonths(0 - ((DateTime.Now.Month - 1) % 3)).AddDays(1 - DateTime.Now.Day).AddDays(-1).ToShortDateString();