Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Feb 2006
    Posts
    138
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Comparing dates in MySQL

    I'm having a problem getting my query to recognize and operate on the date correctly - where am I going wrong here (it pulls all dates, not just the dates less than the variable. The field is a MySQL DATETIME field...

    PHP Code:
    $Date $_POST['year']."-".$_POST['month']."-".$_POST['day'];

    $select "SELECT * FROM LeadTable WHERE LeadDateTime > $Date"
    Help is appreciated! Thanks

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    $Date needs to be enclosed in single quotes.

  • Users who have thanked guelphdad for this post:

    chornbeck (11-10-2011)

  • #3
    Regular Coder
    Join Date
    Feb 2006
    Posts
    138
    Thanks
    11
    Thanked 0 Times in 0 Posts
    Ah, yes... Thank you so much - rookie move


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •