Giovedì, 30 Gennaio 2014 12:04

First Day of the next month

Share this post

Get the First Day of the next month

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

	-- Return the result of the function
	RETURN @ResultVar

END

Letto 24079 volte Ultima modifica il Giovedì, 30 Gennaio 2014 12:04