mysql - Order by date time with AM PM -


I want to write a selected query with the order by datetime field. My date field is in the following format

  2014-04-21 05:30 PM 2014-04-21 06:30 am 2014-04-21 10:30 am   
  SELECT SELECT ORDER by STR_TO_DATE (`date_time`, '% h.% I% p')  

You need to save the date using the DATETIME format in the right format, Makes it easy. However, in your case you can do the form by SELECT * ORDER date_format (STR_TO_DATE (`date_time`, '% y-% m-% d% h:% i% p') ., '% Y-% m-% d% H:% i:% s');



Comments

Popular posts from this blog

asp.net - Procedure or function "Procedure name" expects a parameter "Param name" which was not supplied occurs rarely -

jsp - No mapping found for HTTP request with URI with annotation config Spring MVC and Jetty -

sql server ce - Is there some way to make sqlce3.5 and 4.0 co-exist in the C# project -