These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

To calculate a table field

EmilyChang
Registered: Aug 8 2010
Posts: 10

hello everyone...

here is my table field,for example:

VENDID VENDNAME DATE1 DAY1 DATE2 DAY2 DATE3 DAY3 INVTERM
---------------------------------------------------------------------------------------------------------------------------------
0001 AAA 2010/8/1 4 2010/8/7 6 2010/8/15 10
0002 BBB 2010/7/7 7 2010/7/21 8
0003 CCC 2010/6/6 10
0004 DDD 2010/7/1 3   2010/7/20 9
0005 EEE 2010/7/21 8

I've tried many times and searched through many webs but still can't get the solutions.
I have two problems:

1. The output of field "INVTERM" is a date/time fields. It should be the sum of THE LAST Date and Day.
The value of INVTERM above should be:

VENDID ... INVTERM
----------------------------------------------------------------------------------
0001 ... 2010/8/25
0002 ... 2010/7/29*
0003 ... 2010/6/16
0004 ... 2010/7/29*
0005 ... 2010/7/29*

2. On the form, only VENDNAMEs that have the same INVTERM is showed(with *), for example:

VENDNAME: BBB, DDD, EEE

In question one, I tried to write some scripts with IF-ELSE expression to calculate but somehow it didn't work.
In question two, I want to use the VIEW concept in Database, but I couldn't get the way to do.

Could someone give me some advice?
If there is any confusion on my questions, let me know please.
thank you anyway!

My Product Information:
LiveCycle Designer, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
Can you determine the last date and day entry?

You have to convert the character date strings to the number days since the Epoch date before you can add the days to the date, and then you will have convert that computed number of days since the Epoch date to a date string. Look at the 'Date2Num' and 'Num2Date' FormCalc functions.

You could also break out the year month and day from the JavaScript date object, increment the days and then convert the year, month, and day values back to a date object and then back to a date string.

George Kaiser

EmilyChang
Registered: Aug 8 2010
Posts: 10
Thanks for you reply, gkaiseril

In fact, I can successfully convert the character data string using Num2Date and Date2Num.
My problem is that I can't fetch the every row data in my internal table to calculate.
In my case, there is an internal table

VENDID VENDNAME DATE1 DAY1 DATE2 DAY2 DATE3 DAY3
-------------------------------------------------------------------------------------------------------------
0001 AAA 2010/8/1 4 2010/8/7 6 2010/8/15 10
0002 BBB 2010/7/7 7 2010/7/21 8
0003 CCC 2010/6/6 10
0004 DDD 2010/7/1 3   2010/7/20 9
0005 EEE 2010/7/21 8
...

while when I'm designing my form, I'd like to add another field onto my form to have the data in the table calculated as INVTERM.

the script I tried before :
if (CDATE3.rawValue ne null) then$.rawValue = Num2Date(Date2Num(CDATE3.formattedValue, "YYYY/MM/DD") + CDAY3.rawValue, "YYYY/MM/DD")elseif (CDATE2.rawValue ne null) then$.rawValue = Num2Date(Date2Num(CDATE2.formattedValue, "YYYY/MM/DD") + CDAY2.rawValue, "YYYY/MM/DD")else$.rawValue = Num2Date(Date2Num(CDATE1.formattedValue, "YYYY/MM/DD") + CDAY1.rawValue, "YYYY/MM/DD")endif

Can you get what I mean and give me more direction on my script?
thank you