Highlighted

System Date Calculation

Avatar

Guest

25-06-2008

Good day and thanks in advance for your help. I am new to Adobe users forums as of Yesterday 6-24-08. I am also new to the designing of these forms but I think I am going to like it. My question is: Can I calculate the difference between 2 dates and get a results of make the finish date be 30 days later than the original date.



Example in excel, for instance: Cells A1 & B1 are dates fields and in A1 I use todays date 6/25/08 and in B1 put this coded =A1+29 then B1 results will be show the date of 7/24/08 which is 30 days out.



Is this possible?

Replies

Highlighted

gkaiseril

25-06-2008

Yes, one can use FormCalc functions or the JavaScript date time object.



FormCalc has a "Date2Num()" function to get the number of days since the Epoch date and the "Num2Date()" function to convert the number days since the Epoch date to a date string.



JavaScirpt is more complex and computes dates based on the milliseconds from the Epoch date.



There is more information about the FormCalc date and time functions in the Scripting references provided with LiveCycle Designer.
Highlighted

Avatar

Guest

25-06-2008

Thank you so very much for your immediate response. I have seem some example in the forum, but I can't seem to get it to work. I think I have placed them in the right place on the form here is what I have done thus far:



if (Date1.rawValue ne null) then

Num2Date(Date2Num(Date1.rawValue, "MM/DD/YYYY") + 29, "MM/DD/YYYY")

else

null

endif



Is there anyting else I need to add to make this code work.



Thanks for your help.
Highlighted

gkaiseril

25-06-2008

Have you tried the "formattedValue" and make sure the date string is formatted in the same manner as your parameter srting.
Highlighted

Avatar

Guest

25-06-2008

I am putting the code in the validation script message I was just checking the date string on the binding tab to make sure they were the same. I don't see that pattern in the drop down box, so I just typed it and it stayed in place. I am using the date/time pick calendar, does that make a difference why it might not be working?
Highlighted

gkaiseril

25-06-2008

The code should be in the Calculation event for the B1 field. You really need to use the "formattedValue" as picture in the display field option since there are too many data entry variations for dates.
Highlighted

Avatar

Guest

25-06-2008

Sorry I am so confusing, this is not in excel, the form is created in adobe designer 7.0 and I will try formatedValue as soon and I can research it and see what's is all about. Thanks for all your help, I will keep you informed when I resolved this issue.
Highlighted

Avatar

Guest

26-06-2008

Good Morning GEO



Ok if finally figure out where to insert the code, but for some reason it is giving me a 1900 date in the date 2 field. here is my code, can you tell me what I am doing wrong;



if (Date2.formattedValue ne null) then

Num2Date(Date2Num(Date2.formattedValue, "MM/DD/YYYY") + 29, "MM/DD/YYYY")

else

null

endif
Highlighted

Avatar

Guest

26-06-2008

I have tried formatedValue and rawValue and neither of them work, Please tell me what is wrong. It give me a date of 1/29/1900,in the Date2 field, when I select the current date from a calendar when I use the below code:



If(Date1.rawValue ne null) then

Num2Date(Date2Num(Date1.rawValue, "MM/DD/YYYY") + 29, "MM/DD/YYYY")

else

null

endif



Thanks to anyone who response
Highlighted

Avatar

Guest

29-06-2008

Thanks to all, I finally got it figure out. It took me a moment to understand what I was doing, but I am one of those folks, that will never take no as a final answer. The code for date/time from a calendar do just what I wanted it to do. Count 30 days from the beginning date to the end date.



Thanks for putting on the right path.