Expand my Community achievements bar.

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

Calculating Dates - help please

Avatar

Former Community Member
Hi



I need help with using the Date/time object.

I want to have 2 date/time objects.

Arrival and departure



and have a third numeric text object which will subtract the two dates and calculate the days.



I've gone through the forums and found these 2 topics


Thierry Stortenbeker, "Date Manipulation" #2, 16 Nov 2005 5:27 am

http://www.adobeforums.com/cgi-bin/webx?7@@.3bbd44ca/4



They seem to have provided a solution but i couldn't work out how to use the code because i've never used FormCalc. is it possible to do this in javascript? if not can anyone explain how to use the formcalc script as mentioned here.




Thierry Stortenbeker, "Date Manipulation" #2, 16 Nov 2005 5:27 am



any help would be greatly appreciated

thanks
2 Replies

Avatar

Former Community Member
If all you want to do is find the number of days between two dates, just use the FormCalc function Date2Num. In your third numeric field, add the following to the calculate event...



>Date2Num(DateTimeField1.rawValue, "YYYY-MM-DD") - Date2Num(DateTimeField2.rawValue, "YYYY-MM-DD")



If the result will be more than 365 days, you might want to add code to convert the days into years, months, etc.

Avatar

Former Community Member
Thank you for your quick response, that worked