PDA

View Full Version : Select date greater than


jlsohio
02-10-2008, 10:05 PM
I want to select records > a certain date. How do I modify this statement if I only want to select records > 1/1/08?

$result = mysql_query("SELECT DATE_FORMAT(date, '%m-%d-%y') AS formattedDate , track, race_name, purse, winner, time FROM 2008_road_to_the_jug ORDER BY date ASC, track ASC");

Thank you.

Fumigator
02-11-2008, 01:51 AM
Your string variable you are comparing to needs to be in the format YYYY-MM-DD to properly compare it to a date column in your table.

StupidRalph
02-11-2008, 03:34 AM
For clarity purposes, perhaps you should say "before" or "after" opposed to < or > respectively, when dealing with dates to elucidate what you're trying to say in your question.

$result = mysql_query("SELECT DATE_FORMAT(`date`, '%m-%d-%y') AS `formattedDate` , `track`, `race_name`, `purse`, `winner`, `time` FROM `2008_road_to_the_jug` WHERE `date` > '2008-01-01' ORDER BY `date` ASC, `track` ASC");

jlsohio
02-11-2008, 11:08 PM
Thank you Ralph. It worked.