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

Date calculation

patra
Registered: Oct 19 2006
Posts: 270

Hi everyone,

I have a request for time off form with two fields:
First day off and Day of return to work.
This which I like to accomplish is when the user enter the dates into above fields the Total number of days to show auto into another field(TOTAL DAYS)
and also into another field the Total hours(8 hours per day).
Is that possible?

THANKS

My Product Information:
LiveCycle Designer, Windows
Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi Patra,

Yes, this is possible but requires some knowledge of JavaScript. There are many, many posts here in these forums that cover working with dates- do some searches on DATE and/or TIME calculations and you may find a script that does most of what you want that you can alter to fit your requirements.

Also, there is a series of articles at JavaScript Corner on working with Dates and Time in Acrobat with examples and explanations. Here is a link to Part 1-

http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/date_time_part1/

Hope this helps,

Dimitri
WindJack Solutions
www.windjack.com
www.pdfscripting.com
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Yes, yuo can use the "Date2Num()" funciton in FormCalc to get the number of days since the Epoch date used by LiveCycle Designer, Jan 1, 1900. Once you get the date string converted to days from the fixed date you can compute the difference. Note you will need to pay close attention to the format of the date fields.

FormCalc:

var ReturnDate = "6 Jan 2008"
var FirstDay = "Jan 1, 2008"
Date2Num(ReturnDate, "D MMM YYYY") - Date2Num(FirstDay, "MMM D, YYYY")


It is also possible with JavaScript but this can sometimes be confusing.

George Kaiser

patra
Registered: Oct 19 2006
Posts: 270
Hi gkaiseril ,

Can you give me a little help how to write the script?

Thanks