Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculating number of Quarters between dates

Hi all,

I'm trying to find a way to calculate the number of quarters between a start date and an end date. I believe this is straightforward to do with a DateDiff function, but I cannot see anything similar in QlikView. Any help greatly appreciated.

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

I think this?

year(enddate)*4 + ceil(month(enddate)/3) - year(startdate)*4 - ceil(month(startdate)/3)

That's not normally what I think of when I think "how many quarters are in this range", though.  For instance, I believe that datediff(q, Jan 1 2011, Dec 31 2011) returns 3, even though the date range is a full four quarters.  That's because we only cross 3 quarter boundaries, and datediff is counting boundary crossings, right?

View solution in original post

2 Replies
johnw
Champion III
Champion III

I think this?

year(enddate)*4 + ceil(month(enddate)/3) - year(startdate)*4 - ceil(month(startdate)/3)

That's not normally what I think of when I think "how many quarters are in this range", though.  For instance, I believe that datediff(q, Jan 1 2011, Dec 31 2011) returns 3, even though the date range is a full four quarters.  That's because we only cross 3 quarter boundaries, and datediff is counting boundary crossings, right?

Not applicable
Author

Many thanks John - this is exactly what I required.