Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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?
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?
Many thanks John - this is exactly what I required.