Reputation: 25733
My table looks like this:
Name Created
ganesh 2010-06-25 10:54:54
vasant 2010-06-25 11:54:54
charlie 2010-06-25 12:54:54
sam 2010-06-25 13:54:54
vasamtj 2010-06-25 01:54:54
jack 2010-06-25 02:54:54
nima 2010-06-24 10:54:54
kumar 2010-06-24 10:54:54
jay 2010-06-24 10:54:54
paala 2010-06-23 10:54:54
test1 2010-06-23 10:54:54
jhon 2010-06-22 10:54:54
I want to show only today's entries, in where condition I don't want to add time:
SELECT response FROM ost_ticket_response WHERE staff_id = 1 AND created ='now()'
this query checking with time also.
Upvotes: 0
Views: 106
Reputation: 25733
This query fixed my problem:
SELECT count( response_id ) as cnt, staff_id FROM ost_ticket_response WHERE CAST( created AS Date ) = CURRENT_DATE( ) GROUP BY staff_id
Does this query have any drawbacks?
Upvotes: 0
Reputation: 1
Why not:
SELECT response FROM ost_ticket_response WHERE staff_id = 1 AND DATE(created) = CURDATE()
Upvotes: 0
Reputation: 212412
WHERE Created >= date_format(CURRENT_TIMESTAMP(),'%Y%m%d000000')
Upvotes: 0
Reputation: 297
very rude, but:
SELECT response FROM ost_ticket_response WHERE staff_id = 1 AND created BETWEEN from_days(to_days(now())) AND from_days(to_days(now())+1)
Upvotes: 1
Reputation: 4418
Your table information is not complete but this query will do what you need:
SELECT *
FROM ost_ticket_response
WHERE DATE_FORMAT(Created, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d');
Instead of DATE_FORMAT(NOW(), '%Y-%m-%d')
you can just pass string value '2010-06-25'
from your code
Upvotes: 1