3 Replies Latest reply on Jan 7, 2009 2:45 PM by TBLB

# How to calculate a sum of months in to years and months?

### Title

How to calculate a sum of months in to years and months?

### Post

Hi all,

my problem looks like this:

Date field 1 = start date

Date field 2 = end date

Calculation field gets the result of 50 months for both start and end date for this data record.

Now I want to display this value in "x" Years and "y" Month.

How can I solve this?

Thanks and kind regards

Thorsten

• ###### 1. Re: How to calculate a sum of months in to years and months?

It was easier than expected:

Note: I use the german version.

SetzeVars ([
PRESET = LiesAlsZahl (k_vita_von_bis_calc_monate);
YearMon = LiesAlsZahl (12);
Sum1 = (PRESET / YearMon);
Sum2 = (NächsteKleinereGanzzahl ( sum1 ));
Sum3 = (Sum2 * 12);
Sum4 = (PRESET - Sum3);
ResultY = (Sum2 & " Year/s, ");
ResultM = (Sum4 & " Months");
ResultYM = (ResultY & ResultM)
];
ResultYM
)

/*
& " | PRESET: " & PRESET & " | Sum1: " & Sum1 & " | Sum2: " & Sum2 & " | Sum3: " & Sum3 & " | Sum4: " & Sum4
*/

• ###### 2. Re: How to calculate a sum of months in to years and months?

There is no built-in formatting option for that, you'd have to build a calc field, e.g.:

Int( result/12 )  & " Years and " & Mod( result; 12 ) & " Months"

• ###### 3. Re: How to calculate a sum of months in to years and months?

Hi Tom,

thank you for your hint, will also try that tomorrow, 11:45 pm here, cheers