How to Convert time format in SQL

How to change time to be 1:30:00 am/pm Instead of 13:30:00 ?

You can try below queries.

SELECT substring(convert(varchar(20), GetDate(), 9), 13, 5)
+ ' ' + substring(convert(varchar(30), GetDate(), 9), 25, 2)

declare @time time = '13:30:00' SELECT convert(varchar, @time, 22)

Comments