# Help computing a date, please

Question asked by KarlBrowning on Aug 12, 2011
Latest reply on Aug 12, 2011 by KarlBrowning

### Post

I appreciate any help that you can offer.

I am attempting to add calculated days to a date.  Elements of the calculation use Type "Calculation" fields. (see below).  I have validated that the individual calculations work and display correctly.  But when used in the formula to adjust a date the date field is left null.  I tried to define the date calculation field as a Type "calculation", but that created a meaningless number.  I pray that I am not wasting your time with a parenthesis pairing problem :).

Here are the facts.

1. Field defined as Type "Date" with this calculation (I've tried same formula defining the field as "Calculation"):

PL_WeekEnding_Date +  ( ( ( GetSummary ( PL_avg_Weight ; PL_MoWeek Code ) -  H Resource::UI_Weight Goal )  * 3550  ) /  abs ( PL_Cal_Delta_Weekly ) )

/*      current weight   - goal weight  *   calories/pound  / weekly calorie difference = days

Calculates the projected date the goal weight will be achieved if the current week calorie difference is continued */

Formula substitution example (desired outcome).

PL_Avg_Weight = 266 ; UI_Weight_goal = 230 ; PL_Cal_Delta_Weekly = -1449 ; PL_Weekending_Date = 7/30/11

7/30/11 +  ( ( ( 266 - 230) * 3550 )  / 1449 )

( ( ( 36          ) * 3550 )  / 1449 )

( ( ( 127,800 )             ) / 1449 ) =  88.2

7/30/11 + 88.2  = 11/22/11 (wish this was what was in the field)

2. At the risk of confusing the situation, The field "PL_Cal_Delta_Weekly is defined as a calculation field (not stored) as follows ( I am certain that this produces the correct answer - it prints as such):

If ( Get(CurrentDate) > PL_WeekEnding_Date ;

(GetSummary ( PL_Net_Cals_Sum ; PL_MoWeek Code ) -

GetSummary ( PL_Weight_Maint_sum ; PL_MoWeek Code )) / 7 ;

(GetSummary ( PL_Net_Cals_Sum ; PL_MoWeek Code ) -

GetSummary ( PL_Weight_Maint_sum ; PL_MoWeek Code )) / DayOfWeek ( Get ( CurrentDate )) )

/*  When sorted by week (moweek Code)     Calculates the daily average of calories difference from required maintenance calories */