Level 1

0% to

Level 2

Tip /

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

View all

# Adobe LiveCycle (Archived)

## Calculation Problem

christianw19891
Level 1

Likes

0 likes

Total Posts

12 posts

0 solutions
View profile

christianw19891
Level 1

Likes

0 likes

Total Posts

12 posts

0 solutions
View profile
christianw19891
Level 1

05-11-2015

How to create a formula to calculate integers and dates using formcalc within LiveCylce ? (i.e. Sep 1, 2015 + 1 + 3= Sep 5, 2015)

#### Accepted Solutions (1)

paulk07
Level 4

Likes

29 likes

Total Posts

293 posts

20 solutions
View profile

paulk07
Level 4

Likes

29 likes

Total Posts

293 posts

20 solutions
View profile
paulk07
Level 4

13-11-2015

if (Start.rawValue==null) then

\$.rawValue = ""

else

Num2Date(Date2Num(Start.formattedValue, DateFmt(2))  + stop + ext, DateFmt(2))

endif

2 date fields named Start and Comp

2 numeric fields:  stop and ext

The script is FormCalc on the calculate event of the date field named Comp

christianw19891
Level 1

Likes

0 likes

Total Posts

12 posts

0 solutions
View profile

christianw19891
Level 1

Likes

0 likes

Total Posts

12 posts

0 solutions
View profile
christianw19891
Level 1

18-11-2015

Yes sir. It has been sent.

paulk07
Level 4

Likes

29 likes

Total Posts

293 posts

20 solutions
View profile

paulk07
Level 4

Likes

29 likes

Total Posts

293 posts

20 solutions
View profile
paulk07
Level 4

18-11-2015

Can you send me the form?

christianw19891
Level 1

Likes

0 likes

Total Posts

12 posts

0 solutions
View profile

christianw19891
Level 1

Likes

0 likes

Total Posts

12 posts

0 solutions
View profile
christianw19891
Level 1

18-11-2015

I clicked "right answer" but I am still having issues.

christianw19891
Level 1

Likes

0 likes

Total Posts

12 posts

0 solutions
View profile

christianw19891
Level 1

Likes

0 likes

Total Posts

12 posts

0 solutions
View profile
christianw19891
Level 1

18-11-2015

This the problem I am still having.

christianw19891
Level 1

Likes

0 likes

Total Posts

12 posts

0 solutions
View profile

christianw19891
Level 1

Likes

0 likes

Total Posts

12 posts

0 solutions
View profile
christianw19891
Level 1

18-11-2015

it also gives me a syntax error for this line: "  xfa.host.messageBox("The second date is earlier then the first date.\u000aThe date fields will reset.", "Information", 3, 1) " saying there is an error for "xfa"

paulk07
Level 4

Likes

29 likes

Total Posts

293 posts

20 solutions
View profile

paulk07
Level 4

Likes

29 likes

Total Posts

293 posts

20 solutions
View profile
paulk07
Level 4

18-11-2015

You can leave leave all alone and in the new field add the script.

Syntax:  Without seeing the form structure it's difficult to diagnose but try changing the date field names to StartDate and EndDate

christianw19891
Level 1

Likes

0 likes

Total Posts

12 posts

0 solutions
View profile

christianw19891
Level 1

Likes

0 likes

Total Posts

12 posts

0 solutions
View profile
christianw19891
Level 1

18-11-2015

When you say "same as above" do you mean I can just leave the previous equation I entered and not change anything as far as the field and coding? Also, when I input the new equation you gave me in numeric field called "Days Remaining" it gives me a syntax error for this line: "if (Date2Num(DateField19, "YYYY-MM-DD") &lt; Date2Num(DateField3, "YYYY-MM-DD")) then" saying "syntax error near token "lt""

paulk07
Level 4

Likes

29 likes

Total Posts

293 posts

20 solutions
View profile

paulk07
Level 4

Likes

29 likes

Total Posts

293 posts

20 solutions
View profile
paulk07
Level 4

17-11-2015

same as above except a new field (call it whatever you want)

Add this script to the new field using "calculate":

if (Date2Num(EndDate, "YYYY-MM-DD") and Date2Num(StartDate, "YYYY-MM-DD")) then

if (Date2Num(EndDate, "YYYY-MM-DD") &lt; Date2Num(StartDate, "YYYY-MM-DD")) then

xfa.host.messageBox("The second date is earlier then the first date.\u000aThe date fields will reset.", "Information", 3, 1)

StartDate = null

EndDate = null

\$ = null

xfa.host.setFocus("StartDate")

else

\$ = Date2Num(EndDate, "YYYY-MM-DD") - Date2Num(StartDate, "YYYY-MM-DD") + 1

endif

else

\$ = null

endif

christianw19891
Level 1

Likes

0 likes

Total Posts

12 posts

0 solutions
View profile

christianw19891
Level 1

Likes

0 likes

Total Posts

12 posts

0 solutions
View profile
christianw19891
Level 1

17-11-2015

Awesome! I tried it and everything worked perfect!  I have another equation that I need help with that is very similar to the previous one... I want to take a "Days Allowed" - (End Date - Start Date)= "Days Remaining" (I need it to be an integer, not a date).  Thank you so much for your help!

christianw19891
Level 1

Likes

0 likes

Total Posts

12 posts

0 solutions
View profile

christianw19891
Level 1

Likes

0 likes

Total Posts

12 posts

0 solutions
View profile
christianw19891
Level 1

12-11-2015

The problem I am having is that I want the "Start Date" field and the "+1" "+2" "+3" etc. fields to be input at random.  Each one of the integer fields would be a separate field that the user would enter a number into and it may not be the same number every time.  It may be 1 or it may be 28.  How do I get the form to auto calculate the "start date" plus the two other fields that are changed by the user (ie. "stop days" and "extension days") to get an "Estimated Completion Date"?

paulk07
Level 4

Likes

29 likes

Total Posts

293 posts

20 solutions
View profile

paulk07
Level 4

Likes

29 likes

Total Posts

293 posts

20 solutions
View profile
paulk07
Level 4

09-11-2015

use a date field named StartDate.

Add a text field and add a script written in FormCalc utilizing the calculate function:

if (StartDate.rawValue==null) then
\$.rawValue = ""
else
Num2Date(Date2Num(StartDate.formattedValue, DateFmt(2))  + 1, DateFmt(2))
endif

change the + 1 to increase the number of days calculating from the start date

Date formats can be changed by using DateFMT(1) or DateFMT(2) or DateFMT(3)

or you can create a custom format