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

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.

Ah, silly me, thanks it worked :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.