TSQL Last Day Of The Month

CREATE FUNCTION [dbo].[LastDayOfTheMonth] (@DATE DATETIME )
RETURNS DATETIME
BEGIN
    RETURN dateadd(ms, -3, DATEADD(mm, DATEDIFF(m, 0, @DATE) + 1, 0))
END

Leave a Reply