将 varchar 转换为时间 [英] Convert varchar to time
本文介绍了将 varchar 转换为时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我之前尝试过这里提供的链接来解决类似的问题,但它不起作用.所以我在这里发布我的案例.
I have tried the links available here for similar questions before but it does not work. So I am posting my case here.
我有时间在格式上:
09:47:11:895799
这在我的 Microsoft SQL Server 数据库中存储为 varchar(50)
.
This is stored as varchar(50)
in my Microsoft SQL Server database.
我正在尝试将其转换为时间格式,如此 链接.
I am trying to convert it to time format as on this link.
hh:mm:ss[.nnnnnnn]
你能帮忙吗?
推荐答案
字符串格式错误.它应该是 09:47:11.895799
.您需要将最后的 :
替换为 .
The string is in the wrong format. It should be 09:47:11.895799
. You need to replace the final :
with a .
SELECT CAST(STUFF('09:47:11:895799', 9,1,'.') AS TIME)
这篇关于将 varchar 转换为时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文