What\'s the most efficient way to calculate the last day of the prior quarter?
Example: given the date 11/19/2008, I want to return 9/30/2008.
Platform is S
Get the current date
SELECT CONVERT(DATE,GETDATE()) [Current Date]
Get the 1st date of the quarter for the current date
SELECT CONVERT(DATE, DATEADD(QQ, DATEDIFF(QQ, 0, GETDATE()) ,0)) [Current Quarter 1st Date]
Get the last date of the quarter for the current date
SELECT CONVERT(DATE,DATEADD(d, -1, DATEADD(q, DATEDIFF(q, 0, GETDATE()) +1, 0))) [Current Quarter Last Date]
Get the 1st date of the next quarter for the current date
SELECT CONVERT(DATE, DATEADD(QQ, DATEDIFF(QQ, 0, GETDATE()) +1 ,0)) [Next Quarter 1st Date]
Get the last date of the next quarter for the current date
SELECT CONVERT(DATE,DATEADD(d, -1, DATEADD(q, DATEDIFF(q, 0, GETDATE()) +2, 0))) [Next Quarter Last Date]