Get the First Day of a Month

You are here:
← All Topics

— =========================================================================
— Author : Haroon Mushtaq Abbasi
— Create date : 07-10-2019
— Description : Get the First Day of a Month
— Returns : Start Date of Month
— Test Query : SELECT [dbo].fnGetFirstDateOfMonth
— =========================================================================
ALTER FUNCTION [dbo].[fnGetFirstDateOfMonth]
(
@Month AS SMALLINT,
@Year AS SMALLINT
)
RETURNS DATE
AS
BEGIN
RETURN DATEADD(mm, DATEDIFF(mm, 0, DATEFROMPARTS(@Year,@Month,1)) , 0)
END

Previous Get Name of Month from ID
Next Get the Last Day of a Month
Table of Contents