# How can I add 6 months to a date in a glide table?

**URL:** <https://community.glideapps.com/t/how-can-i-add-6-months-to-a-date-in-a-glide-table/63055>\
**Category:** Ask for Help\
**Created:** [June 22, 2023, 1:51pm UTC](https://community.glideapps.com/t/how-can-i-add-6-months-to-a-date-in-a-glide-table/63055 "2023-06-22T13:51:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![msamps](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/msamps/32/71072_2.png) [@msamps](https://community.glideapps.com/u/msamps)\
**Post date:** [June 22, 2023, 1:51pm UTC](https://community.glideapps.com/t/how-can-i-add-6-months-to-a-date-in-a-glide-table/63055/1 "2023-06-22T13:51:40Z")

</div>

Im trying to calculate a warranty expiry date for 6 months after the sold date. Unfortunately glide only seems to be able to add in days and im trying to calculate exactly 6 months after the date sold. Any ideas or help would be appreciated.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [June 22, 2023, 2:10pm UTC](https://community.glideapps.com/t/how-can-i-add-6-months-to-a-date-in-a-glide-table/63055/2 "2023-06-22T14:10:33Z")

</div>

See below:

> [@If then else with DATE](https://community.glideapps.com/t/if-then-else-with-date/11328/23):
>
> @Darren_Murphy @Milan_Balogh Geez, I had to put on my thinking cap before my morning coffee. The same place that Darren got that original formula had a second formula. It looks like that old thread is unlisted now, so I won’t link to it, but the second formula dealt with adding years, and also accounted for leap year, so if you added 1 year to Feb 29th, then the next year if would calculated to Feb 28th instead of March 1st. Essentially it would figure out if the month of the future calculate…

---

<div class="post-metadata">

**Author:** ![msamps](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/msamps/32/71072_2.png) [@msamps](https://community.glideapps.com/u/msamps)\
**Post date:** [June 22, 2023, 2:39pm UTC](https://community.glideapps.com/t/how-can-i-add-6-months-to-a-date-in-a-glide-table/63055/3 "2023-06-22T14:39:26Z")

</div>

I tried using his formula and some of the values are incorrect. Maybe i’m implementing it wrong. Watching Darrens video now

---

<div class="post-metadata">

**Author:** ![msamps](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/msamps/32/71072_2.png) [@msamps](https://community.glideapps.com/u/msamps)\
**Post date:** [June 22, 2023, 2:52pm UTC](https://community.glideapps.com/t/how-can-i-add-6-months-to-a-date-in-a-glide-table/63055/4 "2023-06-22T14:52:27Z")

</div>

Got it working thank you

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [June 22, 2023, 2:53pm UTC](https://community.glideapps.com/t/how-can-i-add-6-months-to-a-date-in-a-glide-table/63055/5 "2023-06-22T14:53:53Z")

</div>

Excellent 👍

---

<div class="post-metadata">

**Author:** ![Robert\_Petitto](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/robert_petitto/32/25193_2.png) [@Robert\_Petitto](https://community.glideapps.com/u/Robert_Petitto)\
**Post date:** [June 22, 2023, 3:02pm UTC](https://community.glideapps.com/t/how-can-i-add-6-months-to-a-date-in-a-glide-table/63055/6 "2023-06-22T15:02:38Z")

</div>

Here’s a no-code and a low-code way of doing this:

```auto
var dateInput = p1;
var inputDate = new Date(dateInput);

// Adding 6 months to the input date
inputDate.setMonth(inputDate.getMonth() + p2);

// Get the updated date components
var year = inputDate.getFullYear();
var month = ('0' + (inputDate.getMonth() + 1)).slice(-2); // Adding 1 to the month since it is zero-based
var day = ('0' + inputDate.getDate()).slice(-2);

// Constructing the updated date string
var updatedDate = year + '-' + month + '-' + day;

return updatedDate;

```
