php - MYSQL ordering by date (string) -


i have date column formatted this: 28-15.

the format first number tells week, , second 1 year.

i have tried using str_to_date(datecolumn, '%v-%y') no results. orders list not in correct order.

i tried concatting datecolumn make string appear this:

01-28-15 (first day of week) , using str_to_date(datecolumn, '%w-%v-%y), no luck.

what doing wrong?

from mysql docs:

you cannot use format "%x%v" convert year-week string date because combination of year , week not uniquely identify year , month if week crosses month boundary. convert year-week date, should specify weekday:

select str_to_date('200442 monday', '%x%v %w');     

for case, need make assumptions week day(for example monday) , century(for example 2000), can date next way:

select date_add(str_to_date(concat(datecolumn, ' ', 'monday'), '%v-%x %w'), interval 2000 year) 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -