0

我正在尝试仅比较列的日期,但因为下面的查询也在比较我没有返回结果集的时间。

如果我只对实际日期值匹配感兴趣,我怎么能编写相同的 LINQ 查询?

“ImportDate”列的值类似于2009-08-30 12:26:00

from t in UnitsOfWork _
where t.ImportDate = "08/30/2009" _
select t
4

1 回答 1

4

您可以将其作为字符串进行比较,也可以仅使用 ImportDate 上的 Date 属性

where t.ImportDate.ToString("yyyyMMdd") == "20090830"

或者

where t.ImportDate.Date == new DateTime(2009,8,30)
于 2009-08-30T21:02:08.867 回答