C#获取上个月第一天和最后一天
C#获取上个月第一天和最后一天一、获取上个月第一天
private DateTime FirstDayOfPreviousMonth(DateTime datetime)
{
return datetime.AddDays(1 - datetime.Day).AddMonths(-1);
}
二、获取上个月的最后一天
private DateTime LastDayOfPrdviousMonth(DateTime datetime)
{
return datetime.AddDays(1 - datetime.Day).AddDays(-1);
}
三、获取某月的第一天
private DateTime FirstDayOfMonth(DateTime datetime)
{
return datetime.AddDays(1 - datetime.Day);
}
四、获取某月的最后一天
private DateTime LastDayOfMonth(DateTime datetime)
{
return datetime.AddDays(1 - datetime.Day).AddMonths(1).AddDays(-1);
}