Situatie
Mai jos este o procedura ce primeste ca prametru o data si, pentru acea data returneaza ultima zi din luna respectiva/ numarul de zile ale lunii.
Solutie
create procedure LastDayOfMonth_prc
@date date
as
SELECT DAY( DATEADD
( DAY, -1,
DATEADD(MONTH,1,
CAST( CAST(
YEAR(@date) AS VARCHAR(04))
+ RIGHT( (‘0′ + CAST(MONTH(@date) AS VARCHAR(02))) , 2 )
+ ’01’ AS DATETIME)
)
)
)
Leave A Comment?