fistday=format(now,"yyyy-MM-01")
lastday=datediff("d",-1,format(datediff("M",+1,now),"yyyy-MM-01"))

解决方案 »

  1.   

    //当天的时间
    DateTime dt = DateTime.Now;
             //本月第一天时间 
    DateTime dt_First = dt.AddDays( -(dt.Day) + 1);
    //将本月月数+1
    DateTime dt2 = dt.AddMonths(1);
    //本月最后一天时间
    DateTime dt_Last = dt2.AddDays( -(dt.Day) - 1);希望问题得到解决!
      

  2.   

    //本月第一天时间
    DateTime DFirst = 
    DateTime.Parse(DateTime.Now.Year.ToString()+"-"+DateTime.Now.Month.ToString()+"-"+"1");
    //本月最后一天时间
    DateTime DLast;
    if(DFirst.Month != 12)
    DLast = DFirst.AddMonths(1).AddDays(-1);
    else 
    Dlast = DFirst.AddDays(30);