且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何比较EF中DateTime的日期组件?

更新时间:2023-01-29 16:59:38

NOTE: at the time of writing this answer, the EF-relation was unclear (that was edited into the question after this was written). For correct approach with EF, check Mandeeps answer.


You can use the DateTime.Date property to perform a date-only comparison.

DateTime a = GetFirstDate();
DateTime b = GetSecondDate();

if (a.Date.Equals(b.Date))
{
    // the dates are equal
}

上一篇 : :如何在PySpark中的两个日期之间生成每小时的时间戳?下一篇 : Ruby on Rails中多列的索引

相关阅读

技术问答最新文章