Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Subtracting 2 Dates

Avatar

Level 2

Hi,

I'm using LiveCycle Designer 8.1 and am trying to calculate the differnce between 2 date fields.

My script keeps retuning an unexpected values - such as -40,551  (When 09-01-2011 is entered in the form1.Account_Profile_1.DateTimeField3 field and 09-23-2011 is entered in the WO_date_ship_first_order field.)

The code is FormCalc on (exit) from a date field: WO_date_ship_first_order

This is the script: WO_calc_cycle_lead_time.rawValue = Date2Num(WO_date_ship_first_order.formattedValue, "DD-MM-YYYY") - Date2Num(form1.Account_Profile_1.DateTimeField3.formattedValue, "DD-MM-YYYY")

  • WO_calc_cycle_lead_time is my integer field where I am returning thr result
  • WO_date_ship_first_order is the field the script is in and this is a Date field.
  • form1.Account_Profile_1.DateTimeField3 is on another sub-form and is also a Date field.

I am a bit stumped. Both date fields are set as User Entered optional w/ filter date{MM-DD-YYYY}  (data and display)

Thanks ~ Ken

1 Accepted Solution

Avatar

Correct answer by
Level 7

Well you have the pattern set to MM-DD and the Date2Num formula set to DD-MM so it is probably confusing the days and months.

View solution in original post

2 Replies

Avatar

Correct answer by
Level 7

Well you have the pattern set to MM-DD and the Date2Num formula set to DD-MM so it is probably confusing the days and months.

Avatar

Level 2

whyisthisme,

Good Eye!...That was exactly it.

Sorry, I must have been tired.

Thanks ~ Ken