Quantcast
Channel: Steve Stedman » DATEFROMPARTS
Viewing all articles
Browse latest Browse all 3

Using The TSQL EOMONTH Function

$
0
0
Download PDF

Here is a quick video training on how to use the T-SQL EOMONTH function on SQL Server. This was originally part of my free SQL query training for the 70-461 certification exam.

The EOMONTH function returns the last day of a given month, or a future or past month by using the second parameter of offset. EOMONTH was introduced in SQL Server 2012, and is also available in SQL Server 2014 or newer.

Here is the sample code to go with the EOMONTH video tutorial:

-- EOMONTH (2012)
DECLARE @date DATETIME
SET @date = DATEFROMPARTS(2012, 11, 10)
SELECT EOMONTH ( @date ) AS Result;

-- next month end of month
SELECT EOMONTH ( @date, 1) AS Result;

-- last month end of month
SELECT EOMONTH ( @date, -1) AS Result;

See Also

The post Using The TSQL EOMONTH Function appeared first on Steve Stedman.


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles



Latest Images