How to convert a datetime value into a varchar with MM/dd/yyyy HH:MM:SS AM/PM format?
Posted
by
Jyina
on Stack Overflow
See other posts from Stack Overflow
or by Jyina
Published on 2013-08-02T15:33:22Z
Indexed on
2013/08/02
15:35 UTC
Read the original article
Hit count: 129
sql
|sql-server-2008
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
© Stack Overflow or respective owner