Convert Time DataType into AM PM Format:

后端 未结 12 698
悲哀的现实
悲哀的现实 2020-12-23 16:02

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 follo

12条回答
  •  难免孤独
    2020-12-23 16:40

    select CONVERT(varchar(15),CAST('17:30:00.0000000' AS TIME),100)

    almost works perfectly except for the space issue. if that were changed to:

    select CONVERT(varchar(15),CAST('17:30:00.0000000' AS TIME),22)
    

    ...then you get the space. And additionally, if the column being converted is already of TIME format, you can skip the cast if you reference it directly.

    Final answer:

    select CONVERT(varchar(15),StartTime,22)
    

提交回复
热议问题