0

I want to fetch the records from database from a specific date. I have a columns log_date having datetime data type. now I want to get all records which have log date of previous 24 hours.

0

3 Answers 3

2
WHERE log_date BETWEEN DATE_SUB(NOW(), INTERVAL 24 HOUR) AND NOW()

I think that should work, untested though.

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

Comments

2
SELECT * FROM `logtable` WHERE `log_date` > DATE_SUB(NOW(), INTERVAL 24 HOUR)

Comments

2

You could use the BETWEEN statement. If you google on that you will find what you are looking for.

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.