How Can We Help?

Get the Last Day of a Month

You are here:
← All Topics

— =========================================================================
— Author : Haroon Mushtaq Abbasi
— Create date : 07-10-2019
— Description : Get the Last Day of a Month
— Returns : Last Date of Month
— Test Query : SELECT [dbo].fnGetLastDateOfMonth
— =========================================================================
ALTER FUNCTION [dbo].[fnGetLastDateOfMonth]
(
@Month AS SMALLINT,
@Year AS SMALLINT
)
RETURNS DATE
AS
BEGIN

RETURN DATEADD (dd, -1, DATEADD(mm, DATEDIFF(mm, 0, DATEFROMPARTS(@Year,@Month,1)) + 1, 0))

END

Previous Get the First Day of a Month
Table of Contents