sqlserver字符串转为datetime的方法

源数据为'yyyymmddhh24miss',则SQL为

CONVERT(datetime, SUBSTRING(opentime,1,4) +'/'+SUBSTRING(opentime,5,2) +'/'+SUBSTRING(opentime,7,2)+' '    +SUBSTRING(opentime,9,2)+':'+SUBSTRING(opentime,11,2)+':'+SUBSTRING(opentime,13,2), 120)

 至于其他的形式的,可以参考这个做修改。

原文地址:https://www.cnblogs.com/docmao/p/4600379.html