View Thread
 Print Thread
Function to get the first day of the month for a given date
admin
Function to get the first day of the month for a given date


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE FUNCTION [dbo].[udf_GetFirstDayOfMonth] ( @pInputDate DATETIME )
RETURNS DATETIME
    BEGIN

        RETURN CAST(CAST(YEAR(@pInputDate) AS VARCHAR(4)) + '/' +
                CAST(MONTH(@pInputDate) AS VARCHAR(2)) + '/01' AS DATETIME)

    END

GO

Jordon Pilling | Heavencore Administrator
 
Jump to Forum