在其他職位,你的建議使用SQL Server:如何將浮動yyyymmdd轉換爲日期yyyy-mm-dd?
TO_DATE(your_date as String, 'YYYY-MM-DD')
但在SQL Server中沒有的功能to_date
:(
我想是這樣的:
select
start_date2 = replace(substring(cast(start_date as varchar),1,5),'.','') + '-' +
case when substring(cast(start_date as char),6,2) ='1e' then '10' else substring(cast(start_date as char),6,2) end + '-' +
cast(substring(cast(start_date as char),8,2)as char)
from
my_table
但它返回例如:
1971-05-e+
而不是:
1971-05-08
https://msdn.microsoft.com/ en-AU/library/ms187928.aspx –