Reputation: 315
I am using the following to have previous date data at 00.00.00
select * from perf where timeStamp="SUBDATE(CURDATE(),1)";
But this is not resulting any output
where as
select * from perf where timeStamp="2014-11-28";
resulting the proper output
Can anyone of you please help me in trying to find out the issue.Any help is greatly appreciated.
Upvotes: 4
Views: 4406
Reputation: 29051
Check SUBDATE() function
Try this:
SELECT *
FROM perf
WHERE DATE(timeStamp) = SUBDATE(CURDATE(), INTERVAL 1 DAY);
Upvotes: 3
Reputation: 73211
timeStamp="SUBDATE(CURDATE(),1)";
Searches for the string "SUBDATE(CURDATE(),1)" and subdate is wrong executed
remove the " " and it should work like the following:
select * from perf where timeStamp= SUBDATE(CURDATE(),INTERVAL 1 DAY);
Upvotes: 0
Reputation: 12117
1st no need to quote on SUBDATE()
function and, you need to subtract 1 day
select * from perf where timeStamp=SUBDATE(CURDATE(),1);
//or with details of input interval like HOURS
, 'DAY', 'MONTH' etc
select * from perf where timeStamp=SUBDATE(CURDATE(),INTERVAL 1 DAY);
Upvotes: 0