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
BedrockMission!

Learn More

View all

Sign in to view all badges

Calculate the difference between two dates - in Years and Months - not days

Avatar

Avatar
Level 1
logicore
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
logicore
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
View profile
logicore
Level 1

09-08-2017

Let's keep this simple. I want to do THIS: Calculate the difference between two dates - Excel in LiveCycle. Is it possible?

Four columns. Two dates. Two different results:

Start Date/Time Field |  End Date/Time Field |  Years |  Months

Easy peasy.

I can't find a complete answer anywhere. I think this solution would help tons of people.

Thanks for your help!

Accepted Solutions (0)

Answers (1)

Answers (1)

Avatar

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

269 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

269 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile
_Bruce_Robertson
MVP

11-08-2017

Hi,

One way would be to use a library like MomentJS, https://momentjs.com/ .  With this library you could write code like;

moment("2016-06-05").diff("2014-01-01", "months")                for complete months

or

moment("2016-06-05").diff("2014-01-01", "months", true)        for a fractional value

then

moment("2016-06-05").diff("2014-01-01", "years")                   for the year value

Here is an example, MonthsYearsDiff (https://sites.google.com/site/livecycledesignercookbooks/home/MonthsYearsDiff.pdf?attredirects=0&d=1 ), of using this library in a situation like yours, refer to the code in the calculate event of the

MonthsYearsDiff subform.

There is some other examples of date handling in this blog, Adobe LiveCycle Designer Cookbooks by BR001: Date handling in Livecycle Designer ES forms

Regards

Bruce