# Formula for calculating end date of license

My sister can somehow calculate the value for the field `End date` in her head. Can someone please give me the formula that she is using, as I need to use a formula?

https://airtable.com/shrWJArPUxWUy7HG2

``````DATEADD({Signed}, {Length (months)}, "months")
``````

or use the following to avoid errors

``````IF(
AND({Signed}, {Length (months)}),
DATEADD({Signed}, {Length (months)}, "months")
)
``````

That formula does not give the same dates as those in {End date}.

In what way is it different? How exactly is your sister coming up with these dates? If its just simple addition of âsomethingâ to âsomethingâ, you need to express what those somethings are so a proper formula can be written.

Itâs not just a matter of adding something to something, unfortunately.

Letâs take the first license. It was signed 2019-11-01 and has a length of 12 months. Therefor it ended 2020-11-01. Since we are past that date, it was renewed for another 12 months, which gives us a (new) end date of 2021-11-01.

The second license was signed 2020-11-18 and has a length of 36 months. Therefor it ends in 2023-11-18. That date is in the future so thatâs still the actual end date.

Perhaps it is not my place to say, but I would suggest, based on what youâve said here, that you would benefit from modeling your data differently. I would suggest that youâd want the new license to be a separate License record, linked to the same Client record as the âoriginalâ License. You could differentiate the type of license (âOriginalâ, âRenewalâ) with a Single-Select field. Automations or Scripts could be used to automate the process of ârenewingâ a license as much as possible.

Structuring this way makes it much easier to make the sorts of date-based calculations you keep asking for, but in addition, it gives you the added bonus of being able to see a clear history of renewal per Client, statistics of how many times a Client has renewed, whether there were gaps in their renewal history, etc.

1 Like

Thanks for sharing your thoughts, I really appreciate it. If I understood you correctly, you suggest that I use an automation or a script to create a new record when a certain date has passed? That sounds even more complex than what Iâm struggling to do right now Iâll look in to it.

Thanks!

Could I have the automation to create a duplicate of the old record but change a few fields?

Thatâs one possible way to handle it, and as you suggest, it does add a layer of complexity. For somebody that knows how to write automations or scripts, it probably wouldnât be any more complex than writing a Formula that tries to handle dynamic dates, though.

But the main thing, the first thing I am suggesting, is to think of Licenses as records, one new record (row) per new license (whether the license is an original or a renewal of an original). And those License records can be linked to a Client record, one Client record per client you have.

Yes, itâs definitely possible to copy data from an originating record into the new record being created. I would suggest having a Linked Record field on the âLicensesâ table that links back to another License, so that you can link a Renewal license to its original license.

I would urge you to focus on the data model (structure) first though. Establish a manual process by which you can create a new and renewed License record first, so that you know what your workflow looks like. Then, determine the constraints under which you would want to automate that process. You may find that you create an automation too hastily, and find that it is creating renewals when you didnât want it to. To echo the old woodworking adage, âMeasure twice, cut onceââŚ âPlan twice, execute onceâ.

2 Likes

I couldnât get the automation to set the signed field of the created record t0 `DATETIME_FORMAT(TODAY(), 'YYYY-MM-DD')`. Canât you use formulas in the automation fields?

Thatâs basically how itâs setup in my ârealâ base. What Iâm showing in here is just a small portion of it as itâs in Swedish Creating a new record when a field hits a certain criteria was an interesting idea though! Iâm trying to test it right now.

No, you canât use formulas, but you can enter the same date that occupies the âEnd Dateâ field of the record that triggered the automation:

1 Like

Thatâs a smart solution! Thanks! You donât happen to know how to make the formula in my original question? Kamille came close but the last date was wrong.

I wouldnât want to try to figure that out with a formula â which is why I made the suggestion I did. Itâs definitely a challenge, and Iâm sure @kuovonne could figure it out in little time. But itâs not how I would approach the problem, so Iâm not terribly motivated to try and figure it out.

The example given didnât add up correctly to begin with, unless there was some alternate reasoning why the renewal date for 2022-02-01 is 2023-11-01 (21 months) instead of 2024-02-01 (24 months) when the listed `{Length (months)}` value is 24, not 21.

The formula isnât that complex when you break it down, I removed it because it appeared this was already being worked on by a consultant and I didnât want to undercut their business by answering a redundant question for free.

The example I gave you was wrong, your formula was right!

I think your solutions might be better. Iâm trying to set up an automation but I canât get it to work: Test are OK but nothing happens when I turn on the automation. Can you see why?

If youâve asked a question in one thread on the forums, please donât ask it again somewhere else.

Assuming your trigger is âWhen record matches conditionsâ or âWhen record enters a Viewâ, if the record(s) in question already met those conditions/was in that view when the Automation was turned on, the Automation will not run for that record(s). From the Automationâs perspective nothing has changed therefor there was no trigger, therefor the Automation shouldnât run.

You can cut and paste the date value back into the field to force the Automation to run.

Sorry about that! Iâve responded to your post in the other thread.

This topic was solved and automatically closed 15 days after the last reply. New replies are no longer allowed.