Jb. Jb. - 1 year ago 119
MySQL Question

How to convert from datetime format in mysql databse into normal am/pm format?

I am using MySQL for my database and working with Spring.

For export functionality, I am generating a report(excel sheet). In that I have a field called "Created On". I am putting the data i get from database into that field which is in DATETIME format.

like this:
'2016-05-22 17:06:55'

But what I would like to have in my report need to be like this: '05-22-2016 05:06:55 PM'

Thanks in advance.

Answer Source

Use date_format;

select date_format('2016-05-22 17:06:55', '%m-%d-%Y %h:%i:%s %p')


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download