Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL format time with lowercase am/pm

Tags:

sql

mysql

Is there a better way to format a time field to have a lowercase AM or PM? This is what I have in my SELECT statement and it works but it is rather clunky:

CONCAT_WS('', DATE_FORMAT(time, '%l:%i '), LOWER(DATE_FORMAT(`time`, '%p'))) AS time

I guess more importantly is there any significant overhead associated with formatting using SQL functions like this?

like image 885
adamK Avatar asked Jul 11 '12 00:07

adamK


1 Answers

you can directly do it without concactenation.

LOWER(DATE_FORMAT(`time`,'%l:%i %p'))

SEE HERE @ SQLFiddle

like image 144
John Woo Avatar answered Sep 24 '22 02:09

John Woo