# Calculate the date 6 months old from today

Calculate the date 6 months old from today, please advise with recipes

Discussion posts and replies are publicly visible

Parents
• Here is a code snippet that will return 6 months from the previous day. It also takes into account years, so 6 months ago from January will return July of the previous year. I also added error handling for if the day of the month is greater than the number of days in the previous month (i.e no February 31st). In that scenario it will just return the last day of the month.

date(
year(eomonth(today(), -6)),
month(eomonth(today(), -6)),
day(
if(
day(today()) > daysinmonth(month(eomonth(today(), -6)), year(eomonth(today(), -6))),
eomonth(today(), -6),
today()
)
)
)

Just replace all of the -6 with however many months back you want.
• Here is a code snippet that will return 6 months from the previous day. It also takes into account years, so 6 months ago from January will return July of the previous year. I also added error handling for if the day of the month is greater than the number of days in the previous month (i.e no February 31st). In that scenario it will just return the last day of the month.

date(
year(eomonth(today(), -6)),
month(eomonth(today(), -6)),
day(
if(
day(today()) > daysinmonth(month(eomonth(today(), -6)), year(eomonth(today(), -6))),
eomonth(today(), -6),
today()
)
)
)

Just replace all of the -6 with however many months back you want.
Children