I have an aspx document that returns a list of incoming flights from a database in the form of an HTML table. It displays all flights from the current day. The part that generates the rows is:
string fechha = dias + "/" + mess + "/" + años;
string fecVuel = fechha;
for (int i = 0; i <= num - 1; i++)
{
string hora = xl.ChildNodes[0].ChildNodes[i].ChildNodes[5].InnerText;
fecVuel = xl.ChildNodes[0].ChildNodes[i].ChildNodes[0].InnerText;
if (fecVuel == fechha)
{
fila = new TableRow();
What I would like is to have it only get flights that match an specific time period, like 2 hours before and after the current time. In the code, the value of string hora is the time of flight retrieved from the db.
I tried adding a current time variable with rightnow = DateTime.Now.Hour; and adding a conditional, like this:
if (fecVuel == fecha && ((hora >= rightnow - 2) || (hora <= rightnow + 2))) {...
But it’s still generating the entire table. I even tried changing it to fecVuel != fecha but it changes nothing :S I’m not too good with asp, and I’m using Notepad++ for edits. Any ideas? Thanks for your time.
Let’s say right now, it’s 14:00
Two hours ago it was 12:00. In two hours it will be 16:00.
Right now (14:00) will always satisfy one of the two conditions:
Greater than 12:00 OR less than 16:00.
If you change the OR to AND, both conditions must be satisfied.
Only times between 14:00 and 16:00 (not inclusive those times) are selected if you use AND.