I know there is a function to compare just the date of a datetime type column, but what if I want to only compare the time of it to another time. Is there a function in Linq To Entities?
DbFunctions.TruncateTime(q.EndDate.Value)
I know there is a function to compare just the date of a datetime type column, but what if I want to only compare the time of it to another time. Is there a function in Linq To Entities?
DbFunctions.TruncateTime(q.EndDate.Value)
Steve Py
On
It's not pretty, but you can use a combination of a Diff variant method with TruncateTime. For example, to compare a time down to the second:
DbFunctions.DiffSeconds(DbFunctions.TrucateTime(x.Date1), x.Date1) -
DbFunctions.DiffSeconds(DbFunctions.TrucateTime(x.Date2), x.Date2) == 0
Would tell you if the two times (on different dates) are the same or not.
Copyright © 2021 Jogjafile Inc.
I used this and it worked fine.