Home > Blockchain >  Order by String Date in MYSQL Database
Order by String Date in MYSQL Database

Time:12-16

I have data into my table(Students) in MYSQL DB. I want to sort the data based on Date that is VARCHAR(50) column into the MYSQL Database. So, I want a query like Select *from Students where Date_Created => Now() Order by Date_Created

Date_Created

2021-12-17
2021-12-16
2021-12-15
2021-12-15
2021-12-15
2021-12-15
2021-12-15
2021-12-15
2021-12-15
2021-12-15
2021-12-15
2021-12-15
2021-12-15
2021-12-14
2021-12-14``` 

CodePudding user response:

Below working query:

SELECT * FROM Students WHERE Date_Created >= Now() ORDER BY Date_Created;

Test MySQL queries here

Any way I recommend to use date type for store. dates in DB

  • Related