-
Time format in SQL
Hello,
I am taking datetime value from a table MA and separating date and time by using CONVERT function.
CONVERT(VARCHAR(12), MA.ArrivalDate, 101) AS ArrivalDate, '
CONVERT(VARCHAR(12), MA.ArrivalDate, 108) AS ArrivalTime,
but my ArrivalTime is coming as 13:01:00. I want to convert this time as 1:01:00. I have to do this conversion in my stored proc, not in my code. can you help ..? Thanks
-
Re: Time format in SQL
Use a style that does not return the time using the 24 Hour clock. Then parse out the time portion.
LTRIM(SUBSTRING(CONVERT(VARCHAR(30), MA.ArrivalDate, 109) , 12, 9)) AS ArrivalTime