Find end date for a month

How we can find the first and last day of any month? This is a very easy code, this function accepts a offset parameter that would help you to find last of any previous months, or coming months. CREATE FUNCTION getLastDayOfMonth (@dt DATE,@offset INT=0) RETURNS DATE AS BEGIN RETURN Dateadd(d,-1,Dateadd(mm,Datediff(m,0,Dateadd(month,1,@dt))+@offset,0)); END GO See this function in action… Continue Reading Find end date for a month