Igniter
Igniter

Reputation: 615

Sorting date in %W %M %d %Y format in mySql

I want to sort date in msSQL database, which is stored like: Wednesday, February 13, 2016

For example, I have:

-Thursday, January 7, 2016

-Wednesday, February 10, 2016

and this should be sorted like:

I have tried following query: select * from appointment order by date asc;

But it sorts alphabetically, by just seeing first letter of week. How should I sort it by actual timing. Thanks

Upvotes: 1

Views: 148

Answers (1)

Hytool
Hytool

Reputation: 1368

Try this,

    SELECT
            * 
    FROM
            appointment 
    ORDER BY  
            STR_TO_DATE(date, '%W, %M %e, %Y');

Upvotes: 1

Related Questions