Reputation: 199
I have a table where a date is stored as a string: (date_letter_mailed e.g. 3-15-2016)
I need to retrieve records where the stored date (date_letter_mailed) is more than 3 days older the current date.
Using the code shown, no records are retrieved.
SELECT * FROM rec_new_license
WHERE
date_letter_mailed >= (DATE_FORMAT(CURDATE(), '%m-%d-%Y') + 3 DAY)
Also tried:
STR_TO_DATE(date_letter_mailed,'%m-%d-%Y' ) <= DATE_SUB(NOW(), INTERVAL 3 DAY)
Upvotes: 0
Views: 33
Reputation: 6065
Use STR_TO_DATE
SELECT * FROM rec_new_license
WHERE STR_TO_DATE(date_letter_mailed, '%c-%e-%Y') < CURDATE() - INTERVAL 3 DAY
Upvotes: 1