本文介绍了比较数据库中的日期.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
var _tol = from to in ddc.tbl_LeadAssigns
where to.ToDate == DateTime.Today && to.UserId == new Guid(sID)
select to;
foreach (var cnt in _tol)
{
todayCount = todayCount + Convert.ToInt32(cnt.TotalLead);
}
lblToday.Text = todayCount.ToString();
推荐答案
where to.ToDate.Today == DateTime.Today && to.UserId == new Guid(sID)
那可能会解决它.如果没有,那么我们将需要更多信息.
That may fix it. If it doesn''t then we will need a bit more info.
var query = from to in ddc.tbl_LeadAssigns
select new { formatedDate = to.ToDate.Month + "/" + to.ToDate.Day + "/" + to.ToDate.Year, to.UserId };
var _tol = from to in query
where to.formatedDate.Equals(DateTime.Now.ToShortDateString())
select to;
foreach (var cnt in _tol)
{
todayCount = todayCount + Convert.ToInt32(cnt.TotalLead);
}
lblToday.Text = todayCount.ToString();
同样,我离开了很多假设,例如文化等等.
Again there are a lot of assumption that I left, like culture and more.
var _tol = "from to in ddc.tbl_LeadAssigns
where to.ToDate > "+ DateTime.Today + " &&"+ "to.ToDate < "+ DateTime.Today.AddDays(1) +" <pre lang="sql">&& to.UserId == new Guid(sID)
select to;
foreach (var cnt in _tol)
{
todayCount = todayCount + Convert.ToInt32(cnt.TotalLead);
}
lblToday.Text = todayCount.ToString();
最好的问候,
Theingi Win
Best Regard ,
Theingi Win
这篇关于比较数据库中的日期.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!