Reputation: 1165
SELECT CONVERT(time ,' 00:00:12 PM')
Why doesn't the above Code work. What to do to make it Work.
For some reason "00:00:00 PM" to "00:59:59 PM" fails to convert into Time :(
"1:00:00 PM" gets successfully Converted.
Thanks in Advance. Someone please help me out.
Upvotes: 0
Views: 1726
Reputation: 344
00:00 PM does not exist I think. It is either 12:00 AM or 12:00 PM. 00:00 only exists in the 24h format.
Upvotes: 2
Reputation: 998
CONVERT can be used as a CAST but with a FORMAT for dates to get this already well understood literal to be a specific format.
You however want to use PARSE to get this maybe not so well understood literal to become a datetime or time (which doesn't have a format). To tell the engine how to interprrt the literal we type USING.
Check it:
SELECT PARSE(' 00:00:12 PM' AS time USING 'en-US')
Upvotes: 1