Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Date Difference Calculation problem

Avatar

Level 2

I am creating a form which should calculate the number of days between two calender dat

es using the Date2Sum expression but my result cell gives me

zeo despite setting the locale and the calculation correcttly. Where could

my problem be?

Darlington Sakwa

5 Replies

Avatar

Former Community Member

Validate the date patterns on the date fields match the date patterns used in Date2Num. For example, the attached has a start date with the display date pattern date{YYYY-MM-DD} and that matches the date pattern in my Date2Num function call.

// form1.page1.startDateNum::calculate - (FormCalc, client)


if (form1.page1.startDate.isNull) then

  $.rawValue = ""

else

  $.rawValue = Date2Num(form1.page1.startDate.rawValue,"YYYY-MM-DD")

endif

Steve

Avatar

Level 2

Dear Steve,

Thank you for the support.

I actually found out later that the problem was related to the date pattern and I solved the problem.

I am wondering if there is a quick way of excluding weekends in calculating the date difference? This is something I need to implement in a Leave Application Form.

I would like the applicant to enter the start date for leave and the number of days he/she intends to go on leave. The form should calculate the reporting date by excluding the weekend days (Saturdays and Sundays).

Darlington Sakwa

Avatar

Former Community Member

The attached calculates the number of days between two dates and specifies the number of days that are weekdays and the number of days that are on the weekend. It demonstrates how you can determine the day of the week.

Steve

Avatar

Level 2

Thanks a lot Steve,

This is exactly what I was looking for.

Regards

D N Sakwa

Avatar

Level 1

Hello Steve,
I'm new to creating pdf documents and this is exactly what I've been looking forI realize this is an old thread, but is it possible for your to provide your document without a password so I can learn from your script? 

Thank you.