Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Date calculation and formatting

Avatar

Level 2

I have a text box DeliveryDate formatted as Date/Time with binding set to Data Format "DATE" and all patterns set to "MMMM D, YYYY" (which should result in January 5, 2015, etc.).  Dates are picked via the drop down.

I have a floating field LateDueDate formatted as Text, no patterns set.

I am trying to take DeliveryDate and add 30 days and have the result populate LateDueDate.

In the Exit event of DeliveryDate (using FormCalc) I have the following:

EVI_Contract.EVI_Main.PaymentTerms.LateDueDate.formattedValue = Num2Date(Date2Num($.rawValue, "MMMM D, YYYY")+30);

xfa.layout.relayout();

Using various combinations of Num2Date and Date2Num, I have been able to get the function to work on months with short names, i.e. May 1, 2015 will correctly fill LateDueDate with May 31, 2015.  January 1, 2015 results in Jan 1, 1900 - which I recognize is a formatting error -but for the life of me I can't find how to correct it.  I've tried every combination of Num2Date(Date2Num($.rawValue, "MMMM D, YYYY")+30); I can think of, including Num2Date(Date2Num($.rawValue, "MMMM D, YYYYY")+30, "MMMM D, YYYY") and Num2Date(Date2Num($.rawValue +30);, etc.

Thanks in advance!

1 Accepted Solution

Avatar

Correct answer by
Level 7

This worked for me:

DateField2.formattedValue = Num2Date(Date2Num($.formattedValue, "MMMM D, YYYY")+30, "MMMM D, YYYY")

768960_pastedImage_2.png

768961_pastedImage_3.png

768965_pastedImage_4.png

View solution in original post

2 Replies

Avatar

Correct answer by
Level 7

This worked for me:

DateField2.formattedValue = Num2Date(Date2Num($.formattedValue, "MMMM D, YYYY")+30, "MMMM D, YYYY")

768960_pastedImage_2.png

768961_pastedImage_3.png

768965_pastedImage_4.png