//////////////////
declare @DateStr varchar(100)=
'13-09-2019' --or '13/09/2019'
or '2019-09-13'
or
SELECT case when len(isnull(@DateStr ,''))>0 then CONVERT(VARCHAR(10), case when substring(@DateStr ,5,1)='-' or substring(@DateStr ,5,1)='/'then @DateStr else CONVERT(date, @DateStr , 105) end, 23) else null end
//////////////////// Result
2019-09-13 or
2019-09-13 or
2019-09-13 or
NULL
No comments:
Post a Comment