In my previous blog post i have demonstrated how to find first and last date of any month. SQL Server 2012 has introduced a new date function EOMONTH to find the last day of the month.
EOMONTH ( start_date [, month_to_add ] )
Date expression specifying the date for which to return the last day of the month.
Optional integer expression specifying the number of months to add to start_date.
EOMONTH without the month_to_add parameter to find last day of current month
EOMONTH with the month_to_add parameter to find last day of last and next month
SQL Server doesn’t provide any function to find start of the month, but we can make use of EOMONTH function to find start date of any month.
EOMONTH function is available in SQL Server 2012 and higher, for SQL Server 2008 R2 and below you can refer to this blog post.