Adam Gilly Adam Gilly -4 years ago 192
MySQL Question

Convert m/d/yyyy H:MM:SS am/pm to "month d, yyyy" in SQL

How to convert {7/4/2016 5:00:00 Am} to "July 4, 2016" in SQL. This has to be done in SQL only as i need to send the date as in {7/4/2016 5:00:00 Am} format and need to store and retrieve back in "July 4, 2016" format. Huge funtionality depends on just this conversion. please help me out, your solutions are most valuable. Thank you.

Answer Source

If SQL Server 2012+ you can use the format() function

select format(cast('7/4/2016 5:00:00 Am' as datetime),'MMMM d, yyyy')

July 4, 2016
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download