Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
if ((Convert.ToDateTime(dr[0].ToString()) <= Convert.ToDateTime(DateTime.Now.ToShortDateString())))
        {

            Response.Redirect("status.aspx");

        }
        else
        {


                Response.Redirect("login.aspx");

        }
\

what i want is if retrieved date is less than today date or equals to today's date then status page should be opened otherwise login.aspx. but i am not able to do with this code.. it is working fine but when retreived date equals to today's date then it is opening login page.. i want status page to be opened..
Posted

Hi,
see this if it works for you.
C#
if ((Convert.ToDateTime(dr[0].ToString()).ToShortDateString() <= Convert.ToDateTime(DateTime.Now.ToShortDateString())))
{
    Response.Redirect("status.aspx");
}
else
{
    Response.Redirect("login.aspx");
}

Thanks.
 
Share this answer
 
Comments
Harpreet_125 17-Oct-13 3:40am    
it is giving error operatior <= cannot be applied to operands string and string.
Harshil_Raval 17-Oct-13 4:15am    
OK, sorry for that,dr[0].ToString() will have only date value or date and time value?
better you debug code with quick watch, and know what values you are comparing

Quick watch help
http://msdn.microsoft.com/en-us/library/vstudio/0taedcee.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900