can some1 plz tell what line of code do I need to put in the WHERE clause to find all records between 2 dates plz?
PHP Code:$message = mysql_query("SELECT * FROM wwwpages WHERE Language='$lang_choice'") or die(mysql_error());
| SitePoint Sponsor |
can some1 plz tell what line of code do I need to put in the WHERE clause to find all records between 2 dates plz?
PHP Code:$message = mysql_query("SELECT * FROM wwwpages WHERE Language='$lang_choice'") or die(mysql_error());





Do you know the dates to look between already or do you need to calulate a date.
For alreading knowing them assuming you are using datetime fields.
PHP Code:$message = mysql_query("SELECT * FROM wwwpages
WHERE (datefield BETWEEN '$startdate' AND '$enddate') AND Language='$lang_choice'") or die(mysql_error());
If you needed to say grab all between now and two weeks ago.
PHP Code:$message = mysql_query("SELECT * FROM wwwpages
WHERE (datefield BETWEEN DATE_SUB(NOW(), interval 2 week) AND NOW()) AND Language='$lang_choice'") or die(mysql_error());
Please don't PM me with questions.
Use the forums, that is what they are here for.
thank you !!!
it was the first example i needed. Just couldnt rememember it at all!!
ta
Bookmarks