返回首页

我想说明过去三月份的数据在DataList;
我在表中的日期HV一列是datetime类型。
如果用户希望看到的最后3个月的数据,然后他们可以,所以如何计算数据

回答

评论会员:赖斯 时间:2012/02/06
类似


List<datetime> dates = new List<datetime>();

 

DateTime userDate = DateTime.Now;

 

DateTime currentDate = userDate.AddMonths(-3);

 

while (currentDate <= userDate)

{

    dates.Add(currentDate);

    currentDate = currentDate.AddDays(1);

}

 

DataList dl = new DataList();

dl.DataSource = dates;

dl.DataBind();

</datetime></datetime>
评论会员:kishorekke 时间:2012/02/06
SELECT * FROM table WHERE DATEDIFF(mm,date column,getdate())<=3
评论会员:P.Salini 时间:2012/02/06
尝试像
财产以后{体C3}