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