문제

In the db table the time is imported into a field with the following format h:mmt (12 hour:minutes AM/PM designator). The field is a varchar type field. I need to copy this into a field of type time.

I tried select CONVERT(time, '[Time]', 8) but I get the following error: Conversion failed when converting date and/or time from character string.

Any ideas on how I can convert and copy the varchar time to a type of time?

도움이 되었습니까?

해결책

You just need to remove the quotes from around your column name, as you're trying to convert the word [Time] to a time, which won't work.

Try the below:

SELECT CONVERT(time, [Time], 8)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top