Datetime functions
New functions that make datetime
variables easier to handle are always welcome. With SQL Server 2012 there are a number of new functions that we think will really make your programming life much easier. We will explore a number of examples so you can quickly understand how to use them in your everydy code.
EOMONTH
Firstly we will start with the end of month function or, more specifically, EOMONTH, as you will soon learn. This function does exactly what it says, returning the last day of the month you specify. This will no doubt come as a pleasant addition to anyone who runs financial calculations. The syntax is as follows:
DECLARE @MyDate datetime SET @MyDate = '05/17/2012' SELECT EOMONTH (@MyDate) AS LastDayOfTheMonth
As you ...
Get What's New in SQL Server 2012 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.