EOMONTH function SQL Server 2012

Posted by Bandi under Sql Server category on | Points: 40 | Views : 212
EOMONTH() function is introduced in SQL Server 2012. It returns last date of current month. If 2nd argument is specified then specified number of months is added to the start_date and then last date of the month for the resultant date is returned

EOMONTH ( start_date [, month_to_add ] )

1. Finding last date of current month
Select GetDate()As InputDate,EOMONTH (GETDATE()) As Result

InputDate	        Result 
2015-03-20 12:24:23.973 2015-03-31

NOTE: this function is useful to find out last date of previous/next months

Comments or Responses

Login to post response