I'm using mysql workbench, And i need to retrive data of yesterday, but i want the data from a particular timestamp for eg data from 00:00:00 to 12:00:00 how can i do that? And i dont want to change the date everyday. Thankyou
CodePudding user response:
retrive data of yesterday .. from 00:00:00 to 12:00:00
SELECT *
FROM table
WHERE row_timestamp BETWEEN CURRENT_DATE - INTERVAL 1 DAY -- yesterday, 00:00
AND CURRENT_DATE - INTERVAL 12 HOUR; -- yesterday, 12:00
CodePudding user response:
try this
SELECT *
FROM table
WHERE DATE(row_timestamp) = DATE(ADDDATE(NOW(), INTERVAL -1 DAY)
AND HOUR(row_timestamp) < 12