New Eomonth Function in SQL Server 2012

In this article I have described new Eomonth function in SQL Server 2012.
  • 6222

The Eomonth Function

The Eomonth function returns the last day of the month that contains the specified date.

Syntax

The syntax of the "Month" built-in date function is as follows :

MONTH ( startdate [,month_to_add ] )

Here,

The "startdate" parameter can be an expression specifying the date for which to return the last day of the month.

The "month_to_add" is optional.

Example

Select getdate()asCurrentDate

Go

SelectEomonth(getdate())asMonth

Go

SelectEomonth('09/12/2012',2)as Month

Go

SelectEomonth('09/12/2012')asMonth

 

Output

New-SQL-Function12.jpg

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.