Currently I am using this script to pull a time out of a column:
(RIGHT('0' + ltrim(RIGHT(convert(varchar,cast(SUBSTRING(A.DocSign, CHARINDEX('^', A.DocSign) +1, 19) as datetime), 100), 7)), 7))
What this returns is a time formatted like this 10:34AM – It is also converting military time to standard time in this code, and appends it to additional items I am pulling out of columns such as the date, last name, etc. I need the time to display as 10:54:00 AM
So essentially I need to add :00 (always zeros) to the end of any of the times and add a space between the zeros and the AM or PM that is coming in.
I am not very good at formatting, so I am having trouble with this one. Any suggestions?
(I’m running SQL Server 2008 R2)
Without trying to rewrite your expression, I’ll just STUFF the ‘:00 ‘ in.
An alternative is to replace
PM/AMwith the zeroes embedded, i.e.