Expand my Community achievements bar.

SOLVED

Livecycle Date Calculation Incorrect?

Avatar

Level 3

I have a couple of areas of a form that use this code:

DateTimeField2.rawValue = Num2Date(Date2Num(xfa.event.newText, "M/D/YYYY")+30,"MM/DD/YYYY");

Essentially allows you to pick a date which then determines a future date 30 days from the date you chose. Seem simple enough however the date calculated is always off? So if I pick 7-1-2010 it chooses 7-31-2010, if I choose 2-1-2010 it picks 3-3-2010.

I am totally stumped as to why this is occurring and I'm against a wall to make it work. Does anyone have any suggestions?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Date2Num function converts the date to the number. It is then adding 30 to the number and then converting the number back to Date.

During this process it is not considering to include the selected date. So in your case, if you want to have the exact 30 days inclusive of selected date, then try adding only 29 instead of 30.

Hope this helps..

Thanks

Srini

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

Date2Num function converts the date to the number. It is then adding 30 to the number and then converting the number back to Date.

During this process it is not considering to include the selected date. So in your case, if you want to have the exact 30 days inclusive of selected date, then try adding only 29 instead of 30.

Hope this helps..

Thanks

Srini