Compare user entered date with database date time

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ghjk
    Contributor
    • Jan 2008
    • 250

    Compare user entered date with database date time

    I want to compare user entered date with data base datetime value. Database value in datetime type and first i want to extract date part and then compare with user entered value. This is my query. Could someone tell me what is wrong with it?

    [PHP]SELECT * FROM db WHERE Date = SELECT CAST(Date AS DATE) AS dateonly FROM db[/PHP]
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Originally posted by ghjk
    I want to compare user entered date with data base datetime value. Database value in datetime type and first i want to extract date part and then compare with user entered value. This is my query. Could someone tell me what is wrong with it?

    [PHP]SELECT * FROM db WHERE Date = SELECT CAST(Date AS DATE) AS dateonly FROM db[/PHP]
    I'd recommened asking in the mysql forum!

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      This is not a PHP question, but a MySql one. I will move this thread to the MySQL forum.

      moderator

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        You are triple posting! You opened a MySQL thread in the PHP and in two in the MySQL forum. And this question has nothing to do with PHP.

        warning: do not double/triple post, especially not in a non-question releated forum. Not complying on this with the Posting Guidelines on this will result in a ban from this site next time.

        moderator

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          What is the user-entered value in this query?[code=sql]SELECT * FROM db WHERE Date = SELECT CAST(Date AS DATE) AS dateonly FROM db[/code]Ronald

          Comment

          Working...