Entity SQL compares date and time without milliseconds

I am trying to extract some records from an MSSQL database using EntityObject with an EntitySQL query. The field I use for filtering is the datetime type. A generated query projected without a millisecond returns nothing to SQL Server. When I add milliseconds, I get the results.

How can I use EntitySQL to get the result without milliseconds?

thanks.

+5
source share
3 answers

This is not elegant, but it worked for me:

foos.SingleOrDefault(f => f.EntryDate.Year == bar.EntryDate.Year &&
                          f.EntryDate.Month == bar.EntryDate.Month &&
                          f.EntryDate.Day == bar.EntryDate.Day &&
                          f.EntryDate.Hour == bar.EntryDate.Hour &&
                          f.EntryDate.Minute == bar.EntryDate.Minute &&
                          f.EntryDate.Second == bar.EntryDate.Second);
+3
source

- , datetime smalldatetime ( ).

.

,

+1

The workaround I found is at the start date of the sample retention as .ToBinary (), then when you filter only the new DateTime (binaryValue) date and compare with that.

0
source

All Articles