DateTimedt=DateTime.Now;//当前时间
DateTimestartWeek=dt.AddDays(1-Convert.ToInt32(dt.DayOfWeek.ToString("d")));//本周周一
DateTimeendWeek=startWeek.AddDays(6);//本周周日
DateTimestartMonth=dt.AddDays(1-dt.Day);//本月月初
DateTimeendMonth=startMonth.AddMonths(1).AddDays(-1);//本月月末
//DateTimeendMonth=startMonth.AddDays((dt.AddMonths(1)-dt).Days-1);//本月月末
DateTimestartQuarter=dt.AddMonths(0-(dt.Month-1)%3).AddDays(1-dt.Day);//本季度初
DateTimeendQuarter=startQuarter.AddMonths(3).AddDays(-1);//本季度末
DateTimestartYear=newDateTime(dt.Year,1,1);//本年年初
DateTimeendYear=newDateTime(dt.Year,12,31);//本年年末
|
|