How to convert a datetime value into a varchar with MM/dd/yyyy HH:MM:SS AM/PM format?
- by Jyina
I need to convert the below date into the output as shown. I can get the date part using the code 101 but for the time I could not find any code that translates the time to HH:MM:SS AM/PM? Any ideas please? Thank you!
declare @adddate datetime
Set @adddate = 2011-07-06T22:30:07.5205649-04:00
Convert(varchar, @adddate, 101) + ' ' +
Convert(varchar, @adddate, 108)
The output should be 06/07/2011 10:30:07 PM