Situatie
Mai jos este o functie ce primeste ca parametru o data calendaristica si returneaza a cata zi din an este acea data, precum si ce zi a saptamanii este.
Solutie
— select dbo.DayOfYear_fct(‘20211210′)
alter FUNCTION dbo.DayOfYear_fct
(@input datetime)
RETURNS varchar(100)
AS
BEGIN
–declare @input varchar(50) = ’10/01/2003’
declare @output varchar(100)
select @output= ‘The day is ‘ + DATENAME(mm,@input) + ‘ ‘ +DATENAME(dd,@input) + ‘,’+ DATENAME(dw,@input) + ” +
‘ the ‘ + DATENAME(dy,@input)+ ‘th’ + ‘ ‘ +’Day’ +’ Of ‘
+ DATENAME(yy,@input)
RETURN (@output)
END
Leave A Comment?