Mysql previous date
I am using the following to have the previous date data at 00.00.00
select * from perf where timeStamp="SUBDATE(CURDATE(),1)";
But that doesn't lead to an exit
where as
select * from perf where timeStamp="2014-11-28";
the result is correct output
Can any of you please help me in trying to figure out the problem. Any help is greatly appreciated.
+3
user3607869
source
to share
3 answers
Check the SUBDATE () Function
Try the following:
SELECT *
FROM perf
WHERE DATE(timeStamp) = SUBDATE(CURDATE(), INTERVAL 1 DAY);
+2
Saharsh shah
source
to share
1st no need to quote by function SUBDATE()
and you need to subtract 1 day
select * from perf where timeStamp=SUBDATE(CURDATE(),1);
// or with input interval details like HOURS
'DAY', 'MONTH', etc.
select * from perf where timeStamp=SUBDATE(CURDATE(),INTERVAL 1 DAY);
0
Girish
source
to share
timeStamp="SUBDATE(CURDATE(),1)";
Searches for the string "SUBDATE (CURDATE (), 1)" and the count is not correct
remove the "" and it should work like this:
select * from perf where timeStamp= SUBDATE(CURDATE(),INTERVAL 1 DAY);
0
baao
source
to share