SQL Server and BI Tools
Saturday, November 24, 2012
SQL Server Function for GetLastDayOfMonth
CREATE FUNCTION [dbo].[fn_GetLastDayOfMonth]
(
@InputDate datetime
)
RETURNS datetime
BEGIN
RETURN DATEADD(day, -1, DATEADD(month, 1, CAST(CAST(YEAR(@InputDate) AS char(4)) + '/' + CAST(MONTH(@InputDate) AS char(2)) + '/01' AS datetime)))
END
Newer Post
Older Post
Home