圖中出現了兩種時間格式yyyy_mm和yyyy_m,需要把yyyy_m時間格式轉換成yyyy_mm;
解決方案,通過用cas when 和len函數處理。
select case when len(time)=6 then REPLACE(CONVERT(varchar(10),time,120),N'-','-0') else time end as time
from test where FReportDateStr='2019-3'
圖中出現了兩種時間格式yyyy_mm和yyyy_m,需要把yyyy_m時間格式轉換成yyyy_mm;
解決方案,通過用cas when 和len函數處理。
select case when len(time)=6 then REPLACE(CONVERT(varchar(10),time,120),N'-','-0') else time end as time
from test where FReportDateStr='2019-3'