Hi, I'm new to Designer, and I use the Forms part only. I'm looking for how to have a Numeric Field show a calculation of days. The form has two date/time fields and I want my Numeric Field to show how many days.
I'm reading through the FormCalc and am having a lot of trouble. Thank you to anyone that can help.
Views
Replies
Total Likes
Hi,
Assuming you already have 2(DateField1 & DateField2) date fields and a num(DaysDifference) field,
- Navigate to the Exit event of DateField2 (or use the Calculate event of DaysDifference).
- Select FormCalc for Scripting language
if (DateField1.rawValue ne null and DateField2.rawValue ne null) then
DaysDifference.rawValue =
Date2Num(DateField1, "YYYY-MM-DD") - Date2Num(DateField2, "YYYY-MM-DD")
else
DaysDifference.rawValue = ""
endif
PS: you may need to maintain same format as of code. Alternatively, you can make relevant changes in code.
Hope this helps.
Kind regards,
Kiran Buthpur
Thank you for that info!!
This is the message I receive when Previewing PDF:
The overall approach is valid — it checks if both date fields have values and calculates the difference using Date2Num(). However, it throws an error because rawValue is being accessed on unknown or incorrect field names.
Suggested Fix:
if (HasValue(DateField1) and HasValue(DateField2)) then
Date2Num(DateField2.formattedValue, "YYYY-MM-DD") - Date2Num(DateField1.formattedValue, "YYYY-MM-DD")
else
""
endif
Regards,
Karishma.
@DominiqueLo1 Just checking in — were you able to resolve your issue?
We’d love to hear how things worked out. If the suggestions above helped, marking a response as correct can guide others with similar questions. And if you found another solution, feel free to share it — your insights could really benefit the community. Thanks again for being part of the conversation!
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies