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))
Leave a comment