Expand my Community achievements bar.

Adobe LiveCycle Date/Time Field Scripting Question

Avatar

Level 1

I have a date/time field in Livecycle which the end user chooses a random date from.  I need to populate a date 180 days from this date for an eligible to date/time field.  I have tried various javascript and formcalc options with no success.

3 Replies

Avatar

Level 1

Have you figured out how to do this? I'm working on a similar issue.

Avatar

Level 1

Try this site here for a reference: http://eslifeline.wordpress.com/2008/09/26/date-manipulation/

The following was the use case. A form has 2 TextFields Start_Date and End_date

User enters a certain date in the Start_Date text field for example 09/24/08 (MM/DD/YY)

The End_Date should add 90 days to the Start_date and populate the End_Date

The following script would do that

var current = Date2Num(Start_Date.rawValue, “MM/DD/YY”)

var future = current+90

var newDate = Num2Date(future,”MM/DD/YY”)

form1.#subform[0].End_Date.rawValue = newDate 

Validating End Date is later than Start Date

var diff = Date2Num(EndingDate.rawValue, “YYYY-MM-DD”) – Date2Num(StartingDate.rawValue, “YYYY-MM-DD”)
if (diff > 0) then
xfa.host.messageBox(“The End date is later than start date”)
else
xfa.host.messageBox(“PLEASE CHECK….The End date is before the start date”)
endif

Avatar

Level 10

Just one additional tip to the script above.

You always should refer to the formattedValue than the rawValue, because the the formattedValue is in the format you'll see in the date field while the rawValue may be completely diffent.

This is because of the display and edit patterns you can add to fields.

So better is the following script:

var current = Date2Num(Start_Date.formattedValue, “MM/DD/YY”) ...