View Full Version : Comparing dates in MySQL

11-10-2011, 01:31 PM
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...

$Date = $_POST['year']."-".$_POST['month']."-".$_POST['day'];

$select = "SELECT * FROM LeadTable WHERE LeadDateTime > $Date";

Help is appreciated! Thanks :)

11-10-2011, 01:55 PM
$Date needs to be enclosed in single quotes.

11-10-2011, 02:04 PM
Ah, yes... Thank you so much - rookie move :)