Thursday, April 25, 2013

Get Last Day of the Month in SQL Server 2012

Get Last Day of the Month in SQL Server 2012

SQL Server Provides EOMONTH  function to get LAST of the MONTH.  

 Synatx:  Date EOMONTH(Date) 

select EOMONTH(getdate()) "Last Date of the Month"


for ex:  2013-03-31  //output


Next MONTH  last Date

Select EOMONTH(getdate(),1)  "Next Month Last Date"
for ex: 2013-04-30 

Previous Month last date

Select EOMONTH(getdate(),-1)  "Previous Month Last Date"
for ex: 2013-02-28.

Like this User can find any date's Last Day of that Year and Month.
 
Full Syanx:  EOMONTH(DATE,[Months to Add]  return DATE.


Tags: Get last day of the Month in SQL Server 2012, Get Last Date of the Month in SQL Server,
           Get Last day of the Previous Month in SQL Server 2012, Get Last day of the Next Month in SQL Server 2012.

No comments:

Post a Comment