Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Mission!

Learn More

View all

Sign in to view all badges

# Adobe LiveCycle (Archived)

## Script Help - Add to Date

MHaywood323
Level 2

Likes

3 likes

Total Posts

22 posts

Correct Reply

1 solution
Top badges earned
View profile

MHaywood323
Level 2

Likes

3 likes

Total Posts

22 posts

Correct Reply

1 solution
Top badges earned
View profile
MHaywood323
Level 2

14-04-2015

Need a little FormCalc OR JavaScript Help from the Community.

Have a form that has three fields ...  Date Of Birth, Age, and Emancipation Date.

User Selects DOB, then I calculate Age: (Works Fine)

if(DOB.rawValue ne null) then

Floor(((Date2Num(DOB.formattedValue, "MM/DD/YYYY") - Date() )/365.25)*-1)

endif

The Emancipation Date Field is the one I need some help with.

I need to Have that field Calculate the Date the person turns 18 if Age < 18

I think the easiest way is just to add "18" to the YYYY part instead of calculating it due to leap years and such.

Any Suggestions would be very helpful.

#### Answers (1)

MHaywood323
Level 2

Likes

3 likes

Total Posts

22 posts

Correct Reply

1 solution
Top badges earned
View profile

MHaywood323
Level 2

Likes

3 likes

Total Posts

22 posts

Correct Reply

1 solution
Top badges earned
View profile
MHaywood323
Level 2

15-04-2015

So, A solution I found, but not sure it is the best came from this thread: Re: how to calculate future date

var Emancipation = new Date(DOB.formattedValue);

var Adult = new Date(new Date(Emancipation).setMonth(Emancipation.getMonth()+216));

util.printd("mm/dd/yyyy", Adult);

I am using setMonth  to +216 for 18 years ...

It seems to work in all my tests unless there is a better solution.