Search content within the blog

Monday, May 25, 2009

Find First and Last Day of the Current Quarter in SQL Server

I was recently working on a requirement where the user wanted a report with data from the First day to the Last Day of the current Quarter

Here's a simple way to find the Find First and Last Day of the current quarter in SQL Server 2005/2008

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

SELECT DATEADD(qq,DATEDIFF(qq,-1,GETDATE()),-1) as LastDayOfQuarter


FirstDayOfQuarter         LastDayOfQuarter

2009-04-01 00:00:00.000         2009-06-30 00:00:00.000

No comments:

Post a Comment