我尝试了下面的示例函数......我尝试了许多其他方式,但我仍然收到错误为“从字符串转换日期时间时转换失败”..我所尝试的只是从这个函数我返回一个日期时间但是这里的某个地方它仍然是字符串......
请指教
declare @V_Year nvarchar (4), @Test datetime , @t1 as datetime , @t2 as datetime
declare @Mon varchar(5) , @dayz varchar (5) , @GMTStart varchar(20)
set @Mon = '03'
set @t1 = cast ( @Mon as datetime)
set @dayz = '01'
set @t2 = cast ( @dayz as datetime)
SELECT @V_Year = DATEPART(year, getdate())
set @GMTStart = @Mon + '-' + @dayz + '-' + convert(nvarchar,@V_Year)
set @Test = Cast(@GMTStart as datetime)
select @Test