This function returns the days count of the particular month.
Create Function HowManyDays(@Month Varchar(15), @Year Varchar(5)) Returns Int
As
Begin
Declare @Date Varchar(50),
@Days TinyInt
Select @Date = @Year+'-' + @Month + '-01',
@Days = DatePart(Day,DateAdd(Month,1,@Date) -1)
Return @Days
End
Call the function.
select Master.dbo.HowManyDays(4,2017) Days
0 Comments