Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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.
log_date
datetime
WHERE log_date BETWEEN DATE_SUB(NOW(), INTERVAL 24 HOUR) AND NOW()
I think that should work, untested though.
Add a comment
SELECT * FROM `logtable` WHERE `log_date` > DATE_SUB(NOW(), INTERVAL 24 HOUR)
You could use the BETWEEN statement. If you google on that you will find what you are looking for.
Required, but never shown
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.
Explore related questions
See similar questions with these tags.