During a recent SQL Server Reporting Services report writing project I needed to write some SQL to calculate the 1st Monday of the previous month for report parameters
Solution:
The SQL code to calculate the 1st Monday of the Previous Month:
Select DateAdd(d, (7-((datepart(dw, DateAdd(d,0, DateAdd(mm, DateDiff(m, 0,GetDate())-1))) + (7-2))%7, DateAdd(d,0, DateAdd(mm, DateDiff(m,0, GetDate()),0)))
If you have any questions, leave us a comment below, or need any assistance, please do not hesitate to Contact Us |