Saturday, December 19, 2009 7:12 PM
Date Comparison – Entity Framework
A quick tip about how to compare a datetime field in our database and to be extact only the Date part ignoring the time.
Let’s say that we want to find all records that where created today:
Where(@"Day(it.CreatedTime) == Day(CurrentDateTime())
AND Month(it.CreatedTime) == Month(CurrentDateTime())
AND Year(it.CreatedTime) == Year(CurrentDateTime())")
We are using the ESQL functions Day,Month,Year and CurrentDateTime.
If there is a better way please let me know.
Filed under: Entity Framework, ESQL