I am working with this weird database structures, changing database structures is not the option, but how could I fetch data by order this columns ready_for_homes. Some of the data that are in databases are:
Aug 2021
Feb 2020,
August 2020,
Jan 2021,
November 2020
basically either they contain m Y or M Y,
I have tried with ->orderByRaw("STR_TO_DATE(ready_for_homes,'%M %Y') ASC"); but not ordering.
>Solution :
The issue could be that your text dates do not provide a day component. Given that the day doesn’t matter, we can arbitrarily assign each date to the first of the month:
->orderByRaw("STR_TO_DATE(CONCAT('01 ', ready_for_homes), '%d %M %Y')");