我需要根据SSRS参数确定日期才能放入UTC转换函数 在concat中无法识别这些值。
我现在在's'附近收到语法错误。
select concat(s.y+s.m+s.d])
from(
SELECT y.[Value] as y, m.[Value] as m, d.[Value] as d
FROM ssrs.FnSplit(@YEAR,',') y
cross join ssrs.FnSplit(@MONTH,',') m
cross join ssrs.FnSplit(@DAY,',') d
) s
评论前的代码
DECLARE @YEAR varchar(max)='2222,2111'
DECLARE @MONTH varchar(max)='1,2,3'
DECLARE @DAY varchar(max)='1,2'
DECLARE @START_DATE DATE
--SELECT @START_DATE = CAST((SELECT [Value] FROM ssrs.FnSplit(@YEAR,',') AS VARCHAR(4)) + '-' + RIGHT('0' + CAST((SELECT [Value] FROM ssrs.FnSplit(@MONTH,',') AS VARCHAR(2)), 2)
-- + '-' + CAST((SELECT [Value] FROM ssrs.FnSplit(@DAY,',') AS VARCHAR(4))
select concat(y.[Value]+m.[Value]+d.[Value])
from (
SELECT y.[Value], m.[Value], d.[Value]
FROM ssrs.FnSplit(@YEAR,',') y
cross join ssrs.FnSplit(@MONTH,',') m
cross join ssrs.FnSplit(@DAY,',') d
) s
答案 0 :(得分:2)
您在寻找
SELECT DATEFROMPARTS(T1.Value, T2.Value, T3.Value) Dates
--Or CONCAT(T1.Value, '-', T2.Value, '-', T3.Value) StrDates
FROM STRING_SPLIT(@YEAR, ',') T1
CROSS APPLY
STRING_SPLIT(@MONTH, ',') T2
CROSS APPLY
STRING_SPLIT(@DAY, ',') T3;
将STRING_SPLIT()
函数替换为您的FnSplit
。