Mysql query on date as string

Hi, I have my database with date records saved as string.
For example 021221 is the string and represent 2 december 2021.
Now i need to create a query that select rows by considering that string date + 5 days.

I know how to do with date records… so saved as date… but in my case how to do when records are saved as string?

thanks for your help

    $sql = "select * from tablename where item like str_to_date('021221','%d%m%Y') as date"; 

First thing to do is stop saving dates that way. Use a proper date type column then you can use the numerous built-in date functions.

Sponsor our Newsletter | Privacy Policy | Terms of Service