根据当前日期获取本周起止时间

/// <summary>
    /// 本周起止时间
    /// </summary>
    /// <param name="dt"></param>
    /// <returns></returns>
    private string weekrange(System.DateTime dt)
    {
        int weeknow = Convert.ToInt32(dt.DayOfWeek);
        int daydiff = (-1) * weeknow;
        int dayadd = 6 - weeknow;
        string datebegin = System.DateTime.Now.AddDays(daydiff).ToString("yyyyMMdd");
        string dateend = System.DateTime.Now.AddDays(dayadd).ToString("yyyyMMdd");
        return datebegin + "-" + dateend;
    }
 

你可能感兴趣的:(String)