Hi! I need your suggestion for the following request: Calculate the days between two dates at the template level in an Xpath expression.
To simplify the expression, I first tried creating a formula based on two dates from the same CollectionLetterLines record:
@CustCollectionTrans_TransDate and
@CustCollectionTrans_DueDate
But in the end, I need to calculate the day difference between the two dates below:
CollectionLetterHeader/@CollectionLetterDate and
CollectionLetterLines/@CustCollectionTrans_DueDate.
In the attached template, I used a formula that creates a number out of both dates so that I can subtract them:
number(concat(year(@CustCollectionTrans_DueDate),
format(number(month(@CustCollectionTrans_DueDate)),‘00’),
format(number(day(@CustCollectionTrans_DueDate)),‘00’))) -number(concat(year(@CustCollectionTrans_TransDate),
format(number(month(@CustCollectionTrans_TransDate)),‘00’),
format(number(day(@CustCollectionTrans_TransDate)),‘00’)))
As you can see, it doesn’t do the job:
The correct difference between the dates is 45 days. Where am I going wrong? Is there something I’m missing?
I noticed some time and date functions that I’ve also tried to use, but none of them work for my case.
I did my tests on the attached Replica template:
CustCollectionJour.Report_DateDifference_1.docx (83.3 KB)
Thank you very much for your help.