如何在Server中转换格式为dddd mm/dd/yy的字符串?
例如Wednesday 1/9/13
发布于 2013-08-08 01:10:51
一旦你消除了一周中的一天,你可以只转换其馀的价值。
以下工作:
select cast(right(col, len(col) - charindex(' ', col)) as date)
from (select 'Wednesday 1/9/13' as col) t;编辑:
亚伦说得很好。您可以通过使用样式为“1”的convert来确保转换:
select convert(date, right(col, len(col) - charindex(' ', col)) , 1)
from (select 'Wednesday 1/9/13' as col) t;(101不起作用,因为它预计年份为4位数。)
https://stackoverflow.com/questions/18116346
复制相似问题