PHP MySQL date ordering -


ok im trying order results date , time in ascending order far isnt working :(

$kalendarquery = mysqli_query($con, "select people.firstname, people.lastname, people.id, people.avatar, dates.date, dates.time, dates.timezonedate people inner join dates on people.id=dates.invited_id dates.inviter_id='$user_id' , status='1' order str_to_date(concat(dates.date,' ',dates.time), '%d/%m/%y %h:%m')     asc limit 50"); 

i mean doesnt order lowest date biggest

your second parameter str_to_date has match date format in char field; otherwise, conversion return null every row why not being ordered.

so since dates formatted 27.03.2015 using . delimeter, need make sure use . in parameter rather /.

also lower case %y 2-digit year, need %y because you're using 4-digits:

order str_to_date(concat(dates.date,' ',dates.time), '%d.%m.%y %h:%i')     asc 

you didn't give example of time format, can figure out how reading docs date_format(). notice above changed %m %i in time part: using %m both month , minutes wrong.


Comments

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

node.js - Why do I get "SOCKS connection failed. Connection not allowed by ruleset" for some .onion sites? -

matlab - 0-by-1 sym - What do I need to change in order to get proper symbolic results? -