Situatie
Mai jos este o functie ce primeste ca si parametru o data si returneaza numele (luni,marti, miercuri…) ultimei zile din luna careia apartine data primita ca si parametru.
Solutie
–select dbo.LastDayofMonth(‘2023-05-03’)
alter function
NameOfLastDayofMonth
(
@dt datetime
)
returns varchar(max)
as
begin
return
datename(weekday,
dateadd(
day
,-1
,dateadd(
month
,1
,str(year(@dt),4)+’-‘+str(month(@dt),2)+’-01′
)
)
)
end
Go
Leave A Comment?