0

Hi, I'm making a tv guide program and I'm letting the user select a start date and an end date and I need to output all the programmes which fall between those times.

I'm using linq like this to filter the data

var result = from p in programmes
      where p.Start_t.TimeOfDay > Start.TimeOfDay && p.End_t.TimeOfDay < End.TimeOfDay
      select p;

foreach (Programme p in result)
{
string[] arr = { p.Start_t.TimeOfDay.ToString(), p.End_t.TimeOfDay.ToString(), p.Repeat };
 listView1.Items.Add(p.Title).SubItems.AddRange(arr);
}

Start and End are the DateTimes which the user has selected

[img]http://img21.imageshack.us/img21/1961/unledos.png[/img]

As you can see from the image there are some wrong results and i cant work out what i'm doing wrong, most of the results are correct but there are a couple which are wrong.

Thanks

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Skeldave
1

It's doing exactly what you told it to do. Notice the problem times cross the midnight boundary. You need to include the actual date (you know, day/month/year) in the comparison, not just the time.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.