Get First Day of the Quarter

Get First Day of the Quarter

Iā€™m building a Stored Procedure and Report that needs to limit to data created in the previous quarter, only. The assumption is the report will be run on the first day of a new quarter, but could be run any time within the current quarter.

Can be achieved like so:

DECLARE @startDate DATETIME, @endDate DATETIME
SELECT 
 @startDate = DATEADD(qq, DATEDIFF(qq, 0, GETDATE()) - 1, 0),
 @endDate = DATEADD(dd, -1, DATEADD(qq, DATEDIFF(qq, 0, GETDATE()), 0))
Mike250

Australian. Sport. Passionate Cricket Fan. Go Pro. Abseiling. Snorkeling. Travel. Golf R. SQL Server Developer. Three sons. One daughter. Last Trip: New York.

Related Posts
Leave a comment

Your email address will not be published. Required fields are marked *