How Can find Data between Two Date Using LINQ

jewel 801 Reputation points
2024-04-20T10:26:12.9566667+00:00

i wan find data between two date. but all data can't display. only last two data find as result.

Date productID

2024-04-19 15:50:35.7510481 9

2024-04-19 15:50:35.7539253 10

2024-04-19 16:42:54.1178610 1

2024-04-19 16:42:54.1408529 2

2024-04-19 16:42:54.1440315 3

2024-04-19 16:42:54.1472743 4

2024-04-19 16:43:12.9145960 8

2024-04-19 16:43:12.9184212 9

2024-04-19 16:43:12.9218233 10

2024-04-19 20:18:29.3541375 8

2024-04-19 20:18:29.3805648 9

2024-04-19 20:18:29.3840899 11

2024-04-20 00:00:00.0000000 8

2024-04-20 00:00:00.0000000 9

var res=list.ToList().Where(x=>x.Date==firstdate && x.Date<=lastdate);

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,186 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 112.5K Reputation points
    2024-04-20T11:42:48.8466667+00:00

    Maybe like this: .Where( x => x.Date >= firstdate.Date && x.Date <= lastdate.Date ).


0 additional answers

Sort by: Most helpful