简体   繁体   中英

Order by String Date in MYSQL Database

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``` 

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM