2 Replies Latest reply on Jan 1, 2013 1:41 PM by slraymond

# Trouble with weeks elapsed/remaining per quarter calculation.

I have these fields:

z_WeeksElapsed

z_WeeksRemaining

They calculate the number of weeks elapsed in a quarter, whose start date is set by the user in the field QTRStartDate.

They have been functioning properly during our fiscal Q1, which ended on 12/29/12; but with the new quarter being placed last year, on Sunday Dec. 30 2012, z_WeeksElapsed = (-52) and z_WeeksRemaining = 65.

Here are the calculations:

z_WeeksElapsed =

Let (

[

isToday = Get ( CurrentDate ) ;

dayNumEndFiscalQ = DayOfYear ( Date ( Month ( Resources::QTRStartDate ) + 3 ; 0 ; Year ( Resources::QTRStartDate )));

dayNumStart = DayOfYear (Resources::QTRStartDate);

dayNumToday = DayOfYear (isToday);

daysInFiscalQ = dayNumEndFiscalQ - dayNumStart + 1;

daysElapsed = dayNumToday - dayNumStart;

weeksElapsed = Int (daysElapsed/7)

];

weeksElapsed

)

z_WeeksRemaining =

13-z_WeeksElapsed

Can anyone recommend a fix?

• ###### 1. Re: Trouble with weeks elapsed/remaining per quarter calculation.

How about :  int((Get ( CurrentDate )-Resources::QTRStartDate)/7)    ?

(which takes the absolute days instead of the days in that year)

Hope that helps,

Best regards,

Ruben van den Boogaard

Infomatics Software

ruben@infomatics.nl

• ###### 2. Re: Trouble with weeks elapsed/remaining per quarter calculation.

Thanks! I added '+1' at the end, so the current week is counted as elapsed.