Click to See Complete Forum and Search --> : MySql 4.1.14-standard AND


Markbad311
02-01-2006, 11:22 PM
I know how to do Basic Querys with PHP and mySql. Yet I have confusion when it comes to mySql date functions. I currently have a Sql statment like so:


<?
$sql="SELECT * FROM $table_name WHERE `date` BETWEEN DATE_SUB(CURDATE(), INTERVAL 6 DAY) and DATE_ADD(CURDATE(), INTERVAL 1 DAY) ORDER BY 'bar'";
?>



This is the product of people helping me here. What this does (what you probally already know) is take a listing that i enter in at a certain date in the week. and display it for a week then on monday. for the current week.

I would like to keep with this same format but . I would like it to display from today til one month from now. More inporantly I would like a explanation on how this date thing works because I deal with events and dates are everything. Thanks for any help you can provide me with.

MySql 4.1.14-standard
PHP version 4.4.1

chazzy
02-02-2006, 09:10 AM
you can see all date/time functions in mysql here: http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html

for what you want, you would use between CURDATE() and DATE_ADD(CURDATE(), INTERVAL 30 DAYS)