I have one Table which has two fields such as "StartTime" and "EndTime". The DataType of the Two columns are Time.
So the Values of the Table looks like as follows:
TableA:
StartTime EndTime
------------------ ----------------
17:30:00.0000000 17:57:00.0000000
But I need the result as
StartTime EndTime
------------------ ----------------
05:30 PM 05:57 PM
When I select the table. How to get time in AM PM Format?
Try this:
Here are the various ways you may pull this (depending on your needs).
Using the Time DataType:
Using the DateTime DataType:
or
Using @Saikh's answer above, the 2nd option, you can add a space between the time itself and the AM or PM.
Messy I know, but it's the solution I chose. Strange that the CONVERT() doesn't add that space automatically. SQL Server 2008 R2