Date math - how to subtract in months from a date

I have two control fields:
A. Date
B. Slider (months)

I want to take A - B and output is a a date.

For example
A = Dec 2022
B = 3

It should output as Sept 2022.

p.s
Coming from notions where there is so much content on how to do date math formulas and I spent the better part of an hour here and could not find a single thing related to this.

Hi @Brandon_Wentland :blush: !

I think RelativeDate() should help you here :blush:

Something like this should work :

Date.RelativeDate(-3)

Or written using the slider

Your_Date_A.RelativeDate(- Your_Slider_B)

Add-on: Here’s a quick example using RelativeDate() :blush:

The date (the blue one) I used is Today() displayed as MMM YYYY
(Today() is still a full date behind the scene though, the format is really just a display)

There’s a slider to determine the month offset (currently set to 3)

Then, there’s the canvas formula (the green one) which returns the relative date from Today() with an offset of -3 months (so RelativeDate() subtracts the months from today’s date).
The date the formula returns is also formatted as MMM YYYY but again, behind the scene, it’s still a full date :blush: .

The canvas formula is :

Date.RelativeDate(-[Month Offset]) 

And there’s another canvas formula (the orange one) which returns the relative date from Today() with an offset of 3 months this time (so RelativeDate() adds 3 months to today’s date).
Once again, the date RelativeDate() returns is formatted as MMM YYYY but there’s still a complete date behind it :blush: .

The formula is this one:

Date.RelativeDate([Month Offset])

I hope this helps :innocent:

2 Likes

Thank you so much for the help, this did the trick!

My pleasure @Brandon_Wentland :grin: !

I’m very glad to know this helped you moving forward :raised_hands: !

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