Date range, how many days in each quarter

Hello,
I have two dates “Date From” and “Date to”, I want to know how many days within this date range are in Q1/2/3/4. Example:
Date from = 20 May
Date To = 15 Sep
Q1 = 0
Q2 = 41
Q3 = 76
Q4 = 0

I can’t seem to get this done,thanks assistance.
Stijn


stijntienen (BOB member since 2007-08-17)

something like this should work - you will need to make 4 formulas…this one is for q1 but you can use it for all just change the last line of code.

numberVar i := 0;
numbervar q1 := 0;
numbervar q2 := 0;
numbervar q3 := 0;
numbervar q4 := 0;
datevar mydate := date({?Current Period});

numbervar numdays := datediff(‘d’, date({?Current Period}), currentdate);

for i := 1 to numdays step 1 do

(
if mydate in CDate(2008, 01, 01) to CDate(2008, 03, 31) then q1 := q1+1 else
if mydate in CDate(2008, 04, 01) to CDate(2008, 06, 30) then q2:= q2+1 else
if mydate in CDate(2008, 07, 01) to CDate(2008, 10, 31) then q3:= q3+1 else
q4 := q4+1 ;
i := i + 1;
mydate := mydate+1
)
;

q1


dglinka :us: (BOB member since 2004-11-12)

Hello Dglinka,
I copied your proposal and it runs as a swiss clock.
Thanks a lot.
Stijn


stijntienen (BOB member since 2007-08-17)