From the course: .NET Essentials: LINQ for Databases

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Find data within a date range

Find data within a date range - .NET Tutorial

From the course: .NET Essentials: LINQ for Databases

Start my 1-month free trial

Find data within a date range

- [Instructor] I had a question from a student watching my link, Essential Training Course. Basically, the question was how to filter a query based on a date range. The twist of the question was how to do this based on the results of another query. So for this example, I'm querying the orders table, and I'm looking for this specific order. And when I get that order, I'm showing the OrderID, the OrderDate and the ShipName. So let's run this first query. There's my results. Now, what we want to do is find all the orders in our database that are within 30 days after this order. So the order data is 7/8/1996. I need to use that value and the other query to create the range. So what I'm doing is I'm defining a TimeSpan here on line three, for 30 days. Then I'm creating two dates; the start and end date. the originalDate is running this query and getting the OrderDate value. The futureDate is the originalDate + 30 days.…

Contents