dateinfopathdesignerinfopath2010

How to calculate first day of Due date based on frequency in Microsoft Infopath Designer


I am trying to calculate due dates based on the description of the frequency in another field on my form. So I have 3 fields , "Frequency" which contain the description, "Annually", "Semi-annually", "Quarterly".

Then I have "Last Date" where there is a date that someone enters. and then "Due Date". I would want the first day of the selected month be the calculated due date to be in that field.

I have tried to use the "Rules" and set the condition to , when "Frequency" is equal to "Annually" then I did the set field's value, I selected the "Due Date". For the formula I wrote addDays("Last Date", 365). I was wondering if there is a way to select it to be the first day of the month?

Thank you!


Solution

  • Sure, use the concat/substring functions and format it like a date:

    concat(substring(addDays("Last Date", 365), 1, 4), "-", substring(addDays("Last Date", 365), 6, 2), "-01")