EchoFool Posted March 19, 2008 Share Posted March 19, 2008 I have been searching around to find a simple example of how to make a query with a date range... say like: between november 10th 2007 to january 7th 2008 with in the query...but using the date("Y-m-d H:i:s",time()); format to do it. Though i could not find anything for it, not sure if im just putting long winded words into search boxes which comes up with nothing relevant... has any one got a link for me to see one or could you show me a simple example of how it is done? Thankyou Quote Link to comment Share on other sites More sharing options...
JD* Posted March 19, 2008 Share Posted March 19, 2008 Where are you pulling "time" from? It could be as simple as: $result = mysql_query("SELECT * FROM database WHERE date > '2007-11-10' AND date < '2008-01-07'"); But it all depends on how you are getting your ranges Quote Link to comment Share on other sites More sharing options...
EchoFool Posted March 19, 2008 Author Share Posted March 19, 2008 the user inputs the dates to see logs between certain times... When they pickthe dates in the form it puts it into a format : $Start = //user input format of date("Y-m-d H:i:s",time()); $End = //user input format of date("Y-m-d H:i:s",time()); Then with the 2 variables some how put them into the query. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 19, 2008 Share Posted March 19, 2008 $result = mysql_query("SELECT * FROM database WHERE date > '$Start' AND date < '$End'") or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.