Adam Gilly Adam Gilly - 2 months ago 4
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.


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