asp.net 获取 当前日期时间 及 前后N天日期时间(DropDownList数据绑定)

//今天

DateTime now = DateTime.Now;

//前N天

now.AddDays(-N);

//后N天

now.AddDays(N);

#region Nominate news last ten days
        /// <summary>
        /// Bind New To Nominate
        /// zjf add - 20091222
        /// </summary>
        protected void BindNewToNominate()
        {
            int newCount = 0;
            DateTime now = DateTime.Now;
            DateTime nowAgo = now.AddDays(-10);
            ArticleManager artM = new ArticleManager();
            List<Article> lart = new List<Article>();
            lart = artM.GetList(0, int.MaxValue, "", "UpdateTime between '"+nowAgo+"' and '"+now+"'", "UpdateTime desc", ref newCount);
            this.ddl_NewNominate.DataSource = lart;
            this.ddl_NewNominate.DataTextField = "Title";
            this.ddl_NewNominate.DataValueField = "ArticleId";
            this.ddl_NewNominate.DataBind();           
        }
        #endregion

你可能感兴趣的:(asp.net)