TSQL: Month End Date

In SQL 2008 R2 or earlier version:



    DATEADD(month,datediff(month,’20000101′,GETDATE()),’20000101′) as FirstDayOfMonth, 

    DATEADD(month,datediff(month,’20000131′,GETDATE()),’20000131′) as LastDayOfMonth


In SQL Server 2012, a new EOMONTH is introduced:

SELECT EOMONTH(‘2012-08-24’)




This function also takes 2 parameters:

SELECT EOMONTH(‘2012-08-24’,1)

Returns: 2012-09-30


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s