Reputation: 117
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!
Upvotes: 3
Views: 761
Reputation: 117
I was able to fix the error that I was receiving after the value was being calculated. Within the new text box I created, I changed the control to date. Then as a default value, I used this formula msxsl:format-date(Last Date, "MM/dd/yyy"). And the function to use the calendar was there as well! Everything works now! Thank you @user2051770 for guiding me! Much appreciated!
Upvotes: 1
Reputation: 764
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")
Upvotes: 2