I want to get yesterday’s record in exact now hour and minute time
Forexample this is today’s date and time 2023-04-22 14:32:15
I want the records in 2023-04-21 14:32:15
I tried some queries like bottom but non of them works:
SELECT CONCAT(
TIMESTAMPDIFF(DAY,'2023-04-21 13:45:00', '2023-04-22 13:45:00'));
SELECT * FROM message WHERE datetime BETWEEN CURDATE() - INTERVAL 1 DAY AND CURDATE() - INTERVAL 1 HOUR;
>Solution :
Suppose in your SQL table you have column ‘date_time’. Then this type of query you can use :
select * from table_name
where date(date_time)=date(now()-interval 1 day)
and hour (date_time)=hour(now()
and minute(date_time)=minute(now();
note : please check your database server have same timezone