0

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.

5 Answers 5

1

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

Sign up to request clarification or add additional context in comments.

Comments

1

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)

1 Comment

This is the only correct answer that doesn't cause a full table scan (if correctly indexed).
0
WHERE Created >= date_format(CURRENT_TIMESTAMP(),'%Y%m%d000000')

Comments

0

Why not:

SELECT response FROM ost_ticket_response WHERE staff_id = 1 AND DATE(created) = CURDATE()

Comments

0

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?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.