jeudi, 30 janvier 2014 12:04

Last Day of the previous month

Share this post

Get the last day of the previous month

CREATE FUNCTION [dbo].[udf_GetLastDayOfPreviousMonth]
(
	-- 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(@Date)),@Date),120)

	-- Return the result of the function
	RETURN @ResultVar

END

Lu 20771 fois Dernière modification le jeudi, 30 janvier 2014 12:04