denoteone Posted June 1, 2009 Share Posted June 1, 2009 I was given a csv file with a column for dates. they are in this format: 8/27/2008 12:49 i want to pass a variable in my url so that I can search by database so that I return everything from that date on. so the url would be www.mysite.com?date=08/01/2008 can i use that variable to search the date field in my database? something like $date = $_GET['date']; $query = "SELECT *FROM tablename WHERE postDate >= '$date'"; $result = mysql_query($query)or die (mysql_error()); Link to comment https://forums.phpfreaks.com/topic/160528-compare-dates/ Share on other sites More sharing options...
Ken2k7 Posted June 1, 2009 Share Posted June 1, 2009 Depends on what data type postDate is in. Dates in MySQL are usually in format YYYY-MM-DD H:i:s. You don't need the hours, minutes, seconds, but your date should be in YYYY-MM-DD format. So I don't think MM/DD/YYYY is a valid date format. Link to comment https://forums.phpfreaks.com/topic/160528-compare-dates/#findComment-847235 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.