Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Getting records from previous dates

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Getting records from previous dates

Postby inoob » Wed Sep 25, 2013 12:21 pm

Code: Select all
$query = "(SELECT * FROM database WHERE fldDate > DATE_SUB(DATE(NOW()), INTERVAL 1 MONTH) ORDER BY fldDate DESC LIMIT 4)";

$query = "(SELECT * FROM database WHERE fldDate > DATE_SUB(DATE(NOW()), INTERVAL 14 DAYS) ORDER BY fldDate DESC LIMIT 4)";

$query = "(SELECT * FROM database WHERE fldDate > DATE_SUB(DATE(NOW()), INTERVAL 7 DAYS) ORDER BY fldDate DESC LIMIT 4)";


Im a little confused here. It's getting the records by the recent dates, such as today for example, instead of the records from 1 month ago, 14 days ago and 7 days ago. I need the records from those days but 4 records from each. What is the issue here?
inoob
New php-forum User
New php-forum User
 
Posts: 31
Joined: Tue Nov 06, 2012 12:20 pm

Re: Getting records from previous dates

Postby johnj » Fri Sep 27, 2013 8:35 pm

remove the order by and limit to see if it is picking any records.
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.