Hello,
We are trying to create a workflow such that it will store value for field when it will add date field and number of months from another field.
It is set to run:always | run on: Modified records | Repeated runs: yes
What is wrong in the actions? How to do it? We have given months in {{ }} brackets.
Example: {{number}}
That’s not how it works. Calculated fields cannot be added directly to the field. You have to first calculate the value.
It is not able to calculate new date.
{addMonths(format; timestamp; amount)}
{addMonths(Ymd; {P0}; {P1})}
The format “Ymd” has to match exacly your db value how it stores it. This would work for a date field but not a date time filed. Also in your screen shot, you’re not using the calculated field, your using just a normal field. Like in my screen shot you have to choose “Calculated Fields”
Also what have you set the variables P1 and P0 to be?
In DB, it is yyyy-mm-dd
Yes, I am using Calculated Fields
P0 = Date in yyyy-mm-dd(in DB)
P1 = number of months
You’re also missing a closing bracket.
Also the P1 MUST be a date field, not a date/time.
You’re also missing proper brackets around the other variables.
You’re date is definately not formatted properly.
Read the documentation and follow the syntax careflully. It absolutely works.
You are correct! The format value was wrong. We corrected it and now it is showing a date.
{addMonths(Y-m-d; {P0}; {P1})}
Example: {addMonths(format; timestamp; amount)}
We were trying Ymd but it should be Y-m-d
Assuming your timestamp is “now”, you could also use the {Now(Ymd)} calc too.
I have this working well to add a number of months to a contract start date to calculate the contract end date with this formula: {addMonths(m/d/Y; {P0}; {P1})}
However, the contract needs to end one day less than that calculation, and I can’t get the subdays formula to work. I attempted nesting the formulae like this:
{subDays(m/d/Y; {addMonths(m/d/Y; {P0}; {P1})}; 1)}
but that gave me a blank end date in the record. I suspect the format of the subDays is incorrect somehow. Any thoughts on this?
I find half the battle is getting the brackets right. I use Notepad ++, I start with the a single line for each formula I want to use and then start with the outermost formula and work my way inward. Notepad ++ is great about color coding open and close brakets.
I got it. I was using the wrong function name. Here’s the formula that works:
{subtractDays(m/d/Y; {addMonths(m/d/Y; {P0}; {P1})}; 1)}
Thanks for the pointers @pstevens and @rsp !