Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get time in AM/PM 08:00AM format in ms sql

Query I am using =>

select CONVERT(varchar(15),CAST('08:00:00.0000000' AS TIME),100)

output I am getting => 8:00AM

but I want output => 08:00AM
( two digit hours )

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

So how can I get this output

>Solution :

Sql Server way of LPAD

select right('0'+ CONVERT(varchar(15),CAST('08:00:00.0000000' AS TIME),100), 7)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading