I am trying to select data using EFCore 6.0 in .NET Core 2.1 trying to check whether a datetime column is less than DateTime.Now
.
I have tried using DbFunction.DiffMinutes()
but is of no use as I am getting no such function in the DbFunction
class.
Any idea?
Add Microsoft.EntityFrameworkCore
v2.1.1 from Nuget Packages. Then, use SqlServerDbFunctionsExtensions
class for getting Date comparison. Do the following what I have done in my application. I have found difference in minutes between Date1 and Date2:
DbFunctions dfunc = null;
IQueryable<TableName> lQueryableTableName = lObjInitDbContext.gObjServerAuditHistoryDbContext
.ServerAuditHistorys
.Where(x => SqlServerDbFunctionsExtensions
.DateDiffMinute(dfunc, Convert.ToDateTime(Date1), Convert.ToDateTime(Date2)) < 1);
Hope this will help you!!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With