Posts

Showing posts from June, 2009

SQL Server Helper - Date Functions - Get Last Day of the Month

SQL Server Helper - Date Functions - Get Last Day of the Month : "CREATE FUNCTION [dbo].[ufn_GetLastDayOfMonth] ( @pInputDate DATETIME ) RETURNS DATETIME BEGIN DECLARE @vOutputDate DATETIME SET @vOutputDate = CAST(YEAR(@pInputDate) AS VARCHAR(4)) + '/' + CAST(MONTH(@pInputDate) AS VARCHAR(2)) + '/01' SET @vOutputDate = DATEADD(DD, -1, DATEADD(M, 1, @vOutputDate)) RETURN @vOutputDate END GO"

SQL Server Helper - Date Functions - Get First Day of the Month

SQL Server Helper - Date Functions - Get First Day of the Month : "CREATE FUNCTION [dbo].[ufn_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"