Best way to change date format in mysql SELECT?

Can someone please let me know, I need to change the data format 2010-05-14 17:53 on 14/05/2010 17:53 using the mysql select query

+7
mysql
source share
4 answers

try this choice.

 SELECT DATE_FORMAT(datefield, "%d/%m/%Y %H:%i") FROM <TableName> WHERE <clause> 
+7
source share
 select date_format(date_column, "%d/%m/%Y %H:%i") from table_name 
+2
source share

Maybe this link may help you MySQL Manuel

This should do the trick:

 Select DATE_FORMAT(now(),'%d/%m/%Y %H:%i'); 

Within an hour, you can use% H or% h, depending on whether you want to display 24 hours or 12 hours. % H will set 24h,% h will set 12h.

+1
source share

Use DATE_FORMAT to format your date. To solve your conversion, use the following code as a pointer

 SELECT DATE_FORMAT('2010-05-14 17:53', '%d/%m/%Y %H:%i'); 
+1
source share

All Articles