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

Adding days to Date in LiveCycle

CharlesMW
Registered: Jun 9 2010
Posts: 4
Answered

I have created a very simple form where I select a date for the beginning of the week with the Date/Time field selector. I then want it to output the next 6 days, dates in fields.

Something like this:

Select: June 7 2010

Then above the words Monday, Tuesday, Wednesday.... etc
Should Appear 7, 8, 9... etc.

I am really stumped and have tried all typed of JavaScript and FormCalc scripts but not luck.

The Start Date field is called: "DateFrom"

Any help will be appreceated.

My Product Information:
LiveCycle Designer, Windows
--SID--
Registered: May 4 2010
Posts: 31
at the change event of the main date field apply a script that will siimply add to the current date:

to add to current date you have to use Date2Num function.

for instance

Num2Date(Date2Num(user entered date) + x)

dates have to converted to number, for the purpose of adding , and then converted back to dates after addition. "x" can be the no. of days you wanna add.

~~ S I D ~~

CharlesMW
Registered: Jun 9 2010
Posts: 4
Hi Sid

Sorry I am still a little bit lost here. I am really a beginner at this.

I understand that we need to convert the Datey Format to a Integer, do the calculation and then reconvert back to Date Format.

Do I create a Date/Time Field where the result must be or some other field type?
Then do I use *calculate with Javascript or FormCalc to enter the script in?

My Values are, from date is called "DateFrom" , the to date is called "DateTo". The
The Values that I want to fill in will be called "Day1", "Day2", "Day3" etc.


Can you help with the exact script?
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
A sample script for LiveCycle Designer was posted in [url=http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=21539]Calculating Date, Date1....[/url]. The script includes comments that start with the '//'.

George Kaiser

CharlesMW
Registered: Jun 9 2010
Posts: 4
Gkaiseril - Thank you for that script, I uderstand how it works. However I am still confused about where to put it. What do I attache the script to?

If I try a Date/Time Field then it does not work.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Because the script starts with
// get the formatted value of the fieldvar sDate =  $.formattedValue

The referenced field is would be the field with the start date, "DateFrom", and could go in the exit action so the script only runs when the field is entered and exited and not for every calculation.

George Kaiser