Weird Issue with IF Statement
-
Hi all, I'm struggling with a very strange issue regarding an if statement. Please take the following into consideration:
Response.Write(Request.QueryString("action")); Response.Write("If Statement -> "+String(String(dayDate) ==String(String(Request.QueryString("enddate"))))); Response.Write(String(String(dayDate))); Response.Write(String(Request.QueryString("enddate"))); if (Date(dayDate) == Date(Request.QueryString("enddate"))) { Response.Write("svdvdvdvdvdv"); Response.End(); ....
OUTPUT: save if Statement -> false '2007-03-21' '2007-03-25' svdvdvdvdvdv The thing is the if statement is false but it still goes into the if statement .... Why Can someone plz help ... Many thanx in advanceThe only programmers that are better than C programmers are those who code in 1's and 0's..... :) :) Programm3r
-
Hi all, I'm struggling with a very strange issue regarding an if statement. Please take the following into consideration:
Response.Write(Request.QueryString("action")); Response.Write("If Statement -> "+String(String(dayDate) ==String(String(Request.QueryString("enddate"))))); Response.Write(String(String(dayDate))); Response.Write(String(Request.QueryString("enddate"))); if (Date(dayDate) == Date(Request.QueryString("enddate"))) { Response.Write("svdvdvdvdvdv"); Response.End(); ....
OUTPUT: save if Statement -> false '2007-03-21' '2007-03-25' svdvdvdvdvdv The thing is the if statement is false but it still goes into the if statement .... Why Can someone plz help ... Many thanx in advanceThe only programmers that are better than C programmers are those who code in 1's and 0's..... :) :) Programm3r
-
Hi all, I'm struggling with a very strange issue regarding an if statement. Please take the following into consideration:
Response.Write(Request.QueryString("action")); Response.Write("If Statement -> "+String(String(dayDate) ==String(String(Request.QueryString("enddate"))))); Response.Write(String(String(dayDate))); Response.Write(String(Request.QueryString("enddate"))); if (Date(dayDate) == Date(Request.QueryString("enddate"))) { Response.Write("svdvdvdvdvdv"); Response.End(); ....
OUTPUT: save if Statement -> false '2007-03-21' '2007-03-25' svdvdvdvdvdv The thing is the if statement is false but it still goes into the if statement .... Why Can someone plz help ... Many thanx in advanceThe only programmers that are better than C programmers are those who code in 1's and 0's..... :) :) Programm3r
if you want to compare two date-values you shouldn't cast them to strings. use the DateTime.Compare or DateTime.CompareTo methods instead. i.e if(dayDate.CompareTo(DateTime.Parse(Request.QueryString("enddate")) == 0) { // do something here, if the dates are equal } else { ... } - walter