DateTime dt = DateTime.Now; //本月第一天時間 DateTime dt_First = dt.AddDays(1 - (dt.Day)); //獲得某年某月的天數 int year = dt.Date.Year; int month = dt.Date.Month; int dayCount = DateTime.DaysInMonth(year, month); //本月最后一天時間 DateTime dt_Last = dt_First.AddDays(dayCount - 1); dtpDateTime.Value = dt_First; dtpEndTime.Value = dt_Last;
