Quantcast
Channel: SQLcommitted » SQL SERVER 2012
Viewing all articles
Browse latest Browse all 4

Sql Server 2012 function EOMONTH()

$
0
0

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



Viewing all articles
Browse latest Browse all 4

Trending Articles