O'Reilly logo

What's New in SQL Server 2012 by Jon Reade, Rachel Clements

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required