Ali*_*hşi 5 .net c# linq datetime date-comparison
我写了这段代码.但我想忽略时间,我只想比较一天.
from s in sayac_okumalari
where s.okuma_tarihi == startDate && s.sayac_id == sayac_id
group s by new { date = new DateTime(((DateTime)s.okuma_tarihi).Year, ((DateTime)s.okuma_tarihi).Month, ((DateTime)s.okuma_tarihi).Day, ((DateTime)s.okuma_tarihi).Hour, 1, 1) } into g
select new
{
okuma_tarihi = g.Key.date,
T1 = g.Sum(x => x.toplam_kullanim_T1),
T2 = g.Sum(x => x.toplam_kullanim_T2),
T3 = g.Sum(x => x.toplam_kullanim_T3)
};
Run Code Online (Sandbox Code Playgroud)
例如:
25.02.1987 == 25.02.1987
Run Code Online (Sandbox Code Playgroud)
Ram*_*esh 17
用s.okuma_tarihi.Value.Date == startDate.Date.这应该允许您仅比较Date组件.
更新从注释中的讨论看起来用户正在使用NullableType.因此更新了NullableType的解决方案.
| 归档时间: |
|
| 查看次数: |
17629 次 |
| 最近记录: |