Expand my Community achievements bar.

SOLVED

How to calculate years and months from months field?

Avatar

Level 1

Hi,

I am not too familiar with creating calculated fields in LiveCycle. I am look for assistance with creating a formula in FormCalc or Javascript to calculate the number of months entered in one field to years and months in another field. Any assistance would be greatly appreciatedd. Resources are welcomed as well. Thank you.

Example:

Months Entered: 38

Desired Calculated Field: 3yrs 2mos.

1 Accepted Solution

Avatar

Correct answer by
Level 7

This drove me a bit nuts until I found the solution. I hope this works for you

var months = 38 //You can replace this with an input value

this.rawValue = (months / 12 | 0) + " years and " + months % 12 +" months"

View solution in original post

1 Reply

Avatar

Correct answer by
Level 7

This drove me a bit nuts until I found the solution. I hope this works for you

var months = 38 //You can replace this with an input value

this.rawValue = (months / 12 | 0) + " years and " + months % 12 +" months"