How Can We Help?

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

Table of Contents