Reputation: 1
I need a help. This code help us when we put specific dates in box.
But if we want records of last 10days then what should we need to do. Automatic records of last 10 days
$sql = "select * from pub_website where user='$user' && STR_TO_DATE(pdate,'%Y-%m-%d') = '$fromdate' && website='$site'";
Upvotes: 0
Views: 33
Reputation: 964
To select
all records within a certain date range:
SELECT * FROM pub_website WHERE pdate BETWEEN "2015-12-01 00:00:00" AND NOW()
To do this dynamically, so to speak, for the last 10 days:
SELECT * FROM pub_website WHERE pdate BETWEEN DATE_SUB(NOW(), INTERVAL 10 DAY) AND NOW();
Upvotes: 1