Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Weird Issue with IF Statement

Weird Issue with IF Statement

Scheduled Pinned Locked Moved ASP.NET
help
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Programm3r
    wrote on last edited by
    #1

    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 advance

    The only programmers that are better than C programmers are those who code in 1's and 0's..... :) :) Programm3r

    R W 2 Replies Last reply
    0
    • P 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 advance

      The only programmers that are better than C programmers are those who code in 1's and 0's..... :) :) Programm3r

      R Offline
      R Offline
      ritu4321
      wrote on last edited by
      #2

      Programm3r wrote:

      Message

      hmmmmmmmmmmmm i will take the help from google and let you know.

      1 Reply Last reply
      0
      • P 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 advance

        The only programmers that are better than C programmers are those who code in 1's and 0's..... :) :) Programm3r

        W Offline
        W Offline
        Walter_H
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups