Skip to content
Advertisement

last quarter and next quarter

I would like to get the dates for the last quarter and next quarter.

I have tried:

SELECT
convert(date, DATEADD(q, DATEDIFF(q,0,GETDATE()) -1 ,0)) FirstQDate,
convert(date, DATEADD(s,-1,DATEADD(q, DATEDIFF(q,0,GETDATE()),0))) LastQDate 

Advertisement

Answer

Check This

SELECT DATEADD(qq, DATEDIFF(qq, 0, GETDATE()) - 1, 0)-- First day of last quarter
SELECT DATEADD(dd, -1, DATEADD(qq, DATEDIFF(qq, 0, GETDATE()), 0))-- Last day of last quarter
SELECT DATEADD(qq, DATEDIFF(qq, 0, GETDATE()) + 1, 0)-- First day of Next quarter
SELECT DATEADD (dd, -1, DATEADD(qq, DATEDIFF(qq, 0, GETDATE()) +2, 0))-- Last day of Next quarter
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement