mysql: get record count between two date-time
select * from yourtable
where created < now()
and created > concat(curdate(),' 4:30:00 AM')
May be with:
SELECT count(*) FROM `table`
where
created_at>='2011-03-17 06:42:10' and created_at<='2011-03-17 07:42:50';
or use between
:
SELECT count(*) FROM `table`
where
created_at between '2011-03-17 06:42:10' and '2011-03-17 07:42:50';
You can change the datetime as per your need. May be use curdate()
or now()
to get the desired dates.
for speed you can do this
WHERE date(created_at) ='2019-10-21'
select * from yourtable where created < now() and created > '2011-04-25 04:00:00'