# Help colum math

How can I add months, for example if today is May 5th and I add 2 months to it, let it be July 5th, would someone be so kind as to indicate a solution in glidetable, I do not want it in google sheet

This one is tricky. I have a couple solutions but I want to make sure I’m solving the correct problem. Why are you adding two months to a date?

• Just for display purposes?
• or for calculation purposes?

To calculate that if a person registers and indicates that they will be connected for 2 months, I have to add those 2 months to the current date of registration

So you need it for calculation purposes, correct? You’re trying to check to see if today’s day is or is after the month+2 date so you can restrict/hide items in the app?

This is the latest version of my math formula to add months to a date. It will add the specified number of months, but if the calculated date does not contain the same day number, it will back date to the last day of the goal month. (ex. adding 1 month to Jan 31st will calculate to Feb 28th instead of Mar 3rd). I don’t know if this is exactly what you want. You would have to tell us what should happen if the month you calculate 2 months from now doesn’t contain the same day number as the start date.

1 Like

Exactly, something like this is what I’m looking for if today is 5/5/2022 and I add 2 months so the month contains 28 or 30 or 31 days I want 7/5/2022 to come out I don’t know if I’m letting myself be understood

Every month has a day number of 5. Not every month will have a day number of 29, 30, or 31. Those are the situations you need to consider. What do you expect if you add 2 months to December 31st?

What I expect in this situation is that you give me the date 28/02 day 28 month 02

Perfect. Then yes, the math formula in the post that I shared above will work for this. I’ll repost the formula here.

``````((Date-DAY(Date)+15)+TRUNC(Months/12*365.25))
-
DAY((Date-DAY(Date)+15)+TRUNC(Months/12*365.25))
+
DAY(Date)
-
MOD(
(DAY(((Date-DAY(Date)+15)+TRUNC(Months/12*365.25))
-
DAY((Date-DAY(Date)+15)+TRUNC(Months/12*365.25))
+
DAY(Date))-DAY(Date))
,DAY(Date))
``````
5 Likes

Good morning, excellent formula one last query what parameters do I change if I want to add days, months and years

Days is easy, since all date math in glide is in days. To add days to a date, it’s as simple as adding the number of days you want to any date. You don’t need a complicated formula for that.

If you want to add years, then anywhere you see `Months/12` (which calculates the decimal form of years), you should be able to simply replace it with `Years`. Or you can just do the math to figure out how many month are in a year. 12 months in 1 year, 24 months in 2 years, etc.

1 Like