Listing 3: Altering the Definition of the fn_EndOfMonth Function ALTER FUNCTION dbo.fn_EndOfMonth(@dt AS DATETIME) RETURNS DATETIME WITH RETURNS NULL ON NULL INPUT AS BEGIN RETURN DATEADD(month, 1, CONVERT(CHAR(6), @dt, 112) + '01') - 1; END GO 1