SQLcommitted

Committed with SQL

Sql Server 2012 function EOMONTH()

It returns the last day of the month for the given date with an optional offset.

Syntax : EOMONTH ( start_date [, month_to_add ] )

It returns date type.

Example 1:

DECLARE @date DATETIME
SET @date = ’12/1/2011′
SELECT EOMONTH ( @date) AS LastDateOfTheMonth
GO

Output : image

Example 2: Using offset

DECLARE @date DATETIME
SET @date = ’12/1/2011′
SELECT EOMONTH ( @date, 1) AS LastDateOfTheMonth
GO

Output: image

About these ads

April 5, 2012 Posted by | SQL SERVER 2012 | , | Leave a Comment

   

Follow

Get every new post delivered to your Inbox.

Join 60 other followers

%d bloggers like this: