Jueves, 30 Enero 2014 12:04

Last Day of the month

Share this post

Get the Last Day of the month

CREATE FUNCTION [dbo].[udf_GetLastDayOfMonth]
(
	-- Add the parameters for the function here
	@Date datetime
)
RETURNS datetime
AS
BEGIN
	-- Declare the return variable here
	DECLARE @ResultVar datetime

	-- Add the T-SQL statements to compute the return value here
	SELECT @ResultVar = CONVERT(VARCHAR(10),DATEADD(dd,-(DAY(DATEADD(mm,1,@Date))),DATEADD(mm,1,@Date)),120)

	-- Return the result of the function
	RETURN @ResultVar

END

Visto 20503 veces Modificado por última vez en Jueves, 30 Enero 2014 12:04