-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System.Data.SqlClient.SqlException (0x80131904): The datepart hour is not supported by date function dateadd for data type date. #9566
Comments
Can you post debug log output for query in both machines? Ideally, EF Core should generate same query. Also are you connecting to same server from both machines? |
@doublnt Pls share why this was closed!? |
@ErikEJ Sorry, I forgot.Following: I try to separate the query conditions like that public async Task<int> GetTodayQuestionCount()
{
var startTime = DateTime.Now.Date;
var endTime = startTime.addHours(8);
return await Entities
.Where(q => q.IsActive && q.DateAdded >= startTime && q.DateAdded < endTime)
.Select(q => q.QID).CountAsync();
} But I didn't test in my production Environment. I will show the result after it is work in my Production Environment. |
@ErikEJ It's work when I use in my production environment |
I encounter the same error for EF 3.1.12 with It fails since Using this as a workaround, but not sure whether it won't fail with overflow once
|
@ajcvickers Could you please elaborate on why it's not planned? Developers are forced to use quite a hacky and dirty approach to deal with this issue, which isn't that obvious without additional investigation. |
@uladz-zubrycki It was closed by the original poster. If you think there is a bug here, then please attach a small, runnable project or post a small, runnable code listing that reproduces what you are seeing so that we can investigate. |
@ajcvickers Indeed. This change confused me As to the reproduction, original snippet is enough. And here described a reason of such behavior #9566 (comment) It's applicable for EF 3.1.12, haven't tried that with the latest EF version since project, where I faced this problem, is locked to EF 3. |
Using .NET-Core 2.0 and EF-Core 2.0
When I run this code in ubuntu16.04 in Linux , then log show the error, but it is fine when I use in windows
The text was updated successfully, but these errors were encountered: