How to Get First Day and Last Day of a Current Quarter in SQL Server

To get the first day of the current quarter:

SELECT DATEADD(qq, DATEDIFF(qq, 0, GETDATE()), 0)

To get the last day of the current quarter:

SELECT DATEADD (dd, -1, DATEADD(qq, DATEDIFF(qq, 0, GETDATE()) +1, 0))

To get the first day of the previous quarter

SELECT DATEADD(qq, DATEDIFF(qq, 0, GETDATE()) - 1, 0)

To get the last day of the previous quarter:

SELECT DATEADD(dd, -1, DATEADD(qq, DATEDIFF(qq, 0, GETDATE()), 0))

To get the first day of the next quarter:

SELECT DATEADD(qq, DATEDIFF(qq, 0, GETDATE()) + 1, 0)

To get the last day of the next quarter:

SELECT DATEADD (dd, -1, DATEADD(qq, DATEDIFF(qq, 0, GETDATE()) +2, 0))




Comments

Popular posts from this blog

How to Read TOC Headings from word document using C#

List of special Characters in HTML