Displaying Results

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nashyboy
Forum Newbie
Posts: 14
Joined: Thu May 02, 2002 8:46 am

Displaying Results

Post by nashyboy »

Im having trouble with the following - can anyone help?

each entry in my table has a date entry (the date it was added) - but i cant work out the sql to, for example, pull out all results that have been added in the last 30 days or preferably the last 1 month.

Can anyone help me with this with an example

Cheers :)
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

if it is mysql try

Code: Select all

$today = date('Y-m-d', time());
$mresult = $dbo->query("SELECT * from db where date <="$today" AND date >="$today"+INTERVAL 1 MONTH ORDER BY DATE");
and take a look at mysql date and time functions
Post Reply