Warning: session_start() expects parameter 1 to be array, string given in /home/sqlthoug/public_html/blog/wp-includes/class-wp-hook.php on line 341
EOMNTH – SQL Thoughts

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