Reputation: 195
What is the proper way to query all data on current date? a function in mysql that will get the current date in 12:01 am and current date 11:59 pm
select * from tb_data where date between currentdate_starts and currentdate_ends
Upvotes: 2
Views: 3503
Reputation: 91
Without using DATE(column) = CURDATE()
SELECT * FROM tb_data WHERE date between concat(curdate(),' ','00:00:00') AND concat(curdate(),' ','23:59:59')
Upvotes: 5
Reputation: 2006
Try using CURDATE()
SELECT field FROM table WHERE DATE(column) = CURDATE()
select * from tb_data where DATE(date) = CURDATE()
Documentation: CURDATE
Upvotes: 5
Reputation: 6202
well since there are so many answers. Try this one too and see if it's faster
SELECT * FROM tb_data WHERE date BETWEEN CURDATE() AND (CURDATE()+INTERVAL 1 DAY-INTERVAL 1 SECOND)
Upvotes: 2
Reputation: 29071
Use CURRENT_DATE() or CURDATE() function.
Try this:
SELECT * FROM tb_data WHERE DATE(dateCol) = CURRENT_DATE();
OR
SELECT * FROM tb_data WHERE DATE(dateCol) = CURDATE()
Upvotes: 2
Reputation: 13484
CURDATE() returns the current date.
SELECT * from FROM tb_data WHERE DATE(column) = CURDATE()
Upvotes: 2