I’ve created a program will need to add items if the items are between a date, this is the code I use:
if (day >= fromDay - 1 && day <= tillDay && month >= fromMonth - 1 && month <= tillMonth && year >= fromYear - 1 && year <= tillYear)
{
listBox1.Items.Add(OpenFiles[m_index].getFileName());
}
The code works fine but it has a fault in it: It checks if the day, month and year is between the start and stop.
So even you want to add something from the 19.02.2011 till the 15.04.2011, it doens’t add or see anything. Please help me with this.
You should compare dates rather than the components of the dates:
(Of course, for a date type instead of date and time, have a look at Noda Time 🙂