Wednesday, 20 February 2013

New features in SQL Server 2012

EOMONTH(): Returns the last day for a specified month

Syntax: EOMONTH ( start_date [, month_to_add ] )

start_date:Date expression specifying the date for which to return the last day of the month.

month_to_add (Optional):integer expression specifying the number of months to add to start_date.

SELECT EOMONTH (GETDATE()) AS 'Last day of This Month';
Last day of This Month

SELECT EOMONTH (GETDATE(),1 ) AS 'Last day of Next Month';
Last day of Next Month

SELECT EOMONTH (GETDATE(),-1 ) AS 'Last day of Last Month';
Last day of Last Month

<<LAG()                                                           Go To Main Page

No comments:

Post a Comment