Situatie
Deoarece m-am lovit de aceasta problema, am facut o procedura ce returneaza data de inceput a unui trimestru calendaristic din trecut, si prima zi de luni din acel trimestru.
Procedura primeste un parametru de tip intreg, @n, si se intoarce in timp @n trimestre.
Solutie
create procedure BD_NthPreviousQuarter_prc
@n int
as
SELECT
DATEADD(qq, DATEDIFF(qq, 0, GETDATE()) -@n, 0) as BeginingOfPreviousQuarter,
DATEADD(wk,DATEDIFF(wk,0,DATEADD(qq, DATEDIFF(qq, 0, GETDATE()) -@n, 0)),0) as FirstMondayOfTheQuarter
Leave A Comment?