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)

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

posted @ 2015-06-25 17:04  猫博士  阅读(6239)  评论(0编辑  收藏  举报