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

Calculating Date, Date1....

toddm65
Registered: Aug 23 2009
Posts: 4
Answered

I have a form that I have created. I have a field named Date, Date1, Date2, Date3, Date4. What I am doing is wanting to enter Date (Whatever the date is for the current Monday) and have the form fill in the rest of the weeks dates for me. I am new to using Acrobat so Hopefully this is an easy thing for you experts... :-) Thanks for your help...

My Product Information:
Acrobat Pro 8.0, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
Dates a handled a little differently in AcroForms and LiveCycle Designer, so you will need to make sure you know what form creating program you are using.

Have you looked at Thom Parker's tutorials on date and time calculations?

George Kaiser

toddm65
Registered: Aug 23 2009
Posts: 4
How do I find out what program? I am working on a form that was created in WORD and convrted to PDF. Then I manually put in the field boxes. I put labels on them and did that by clicking on the EDIT LAYOUT button in Acrobat. Do not know what Thom Parker's tutorials are... Where do I find them???
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
I usually look at the window title bar at the top of the application, or use "Help => About ..." from the application's menu bar.Since Acrobat does not have labels on their form fields, it sounds like you are using LiveCycle Designer.

LiveCycle Designer includes a scripting reference within the application. You will find it under 'Help => Scripting Reference'. This document describes the language FormCalc unique to LiveCycle Designer and how JavaScirpt for LiveCycle Designer is different from Acrobat's JavaScript.FormCalc has a number of built in functions among which are 'Date2Num()' and 'Num2Date()' that can convert a date string of a known format to the number of days from a fixed Epoch date and this information allows one to perform a number of date calculations. Once the number of days from the Epoch date has been calculated, one uses the 'Num2Date()' function to convert this number back to a formatted date string. By converting a date string to the number of days and then back, one can reformat the date string to a different layout or extract a given date parameter.

When using these date functions one needs to make sure the format string for the date matches the data being passed to the function or the conversion will not work.

So to get the date strings for a series of dates and performing the calculation on exiting the field one could use for the 'exit' script:

// get the formatted value of the fieldvar sDate =  $.formattedValue// convert the formatted value to the number of daysvar fDate = Date2Num(sDate, "MM/DD/YYYY")// compute day + 1var fNewDate = fDate + 1// fill next day' fieldDate1 = Num2Date(fNewDate, "MM/DD/YYYY")// compute day + 2fNewDate = fDate + 2// fill next day' fieldDate2 = Num2Date(fNewDate, "MM/DD/YYYY")// compute day + 3fNewDate = fDate + 3// fill next day' fieldDate3 = Num2Date(fDate, "MM/DD/YYYY")// compute day + 4fNewDate = fDate + 4// fill next day' fieldDate4 = Num2Date(fNewDate, "MM/DD/YYYY")

George Kaiser