Dear Community,
hope someone can help me out with this!
The formula below indicates based on {Check in date} and {Check out date} how many months a booking of a rental apartment is actually in the current quarter. However in this formula, when the check in date is higher then the 17th of the month in gives one month less. So lets say check in date 17th of October and check out on the last day of December, it gives 3 months. Anything above the formula gives 2 months. However, this is not correct. For any date above the 17th of the month it should also give 3 months as the booking falls into 3 months of the quarter. Obviously if a new month start then it should give 2 months so 1/11 till 31/12 is 2 months. Can someone please help me write a correct formula for this?
The formula below was created by Airtable support, but incorrect and they did not want to help me further! Thank you so much!!!
How to calculate number of months are included within a quarter based in check in and check out day

ROUND(
IF({Check out date}<=DATETIME_PARSE(DATETIME_FORMAT(IF(MOD(MONTH(TODAY()), 3) = 0, MONTH(TODAY()) - 2 &'/01/' &YEAR(TODAY()), FLOOR(MONTH(TODAY()) / 3) * 3 + 1&'/01/' &YEAR(TODAY())),'MM/DD/YYYY')),0,
IF(AND({Check in date}<=DATETIME_PARSE(DATETIME_FORMAT(IF(MOD(MONTH(TODAY()), 3) = 0, MONTH(TODAY()) - 2 &'/01/' &YEAR(TODAY()), FLOOR(MONTH(TODAY()) / 3) * 3 + 1&'/01/' &YEAR(TODAY())),'MM/DD/YYYY')),{Check out date}<=DATEADD(DATEADD(DATETIME_PARSE(DATETIME_FORMAT(IF(MOD(MONTH(TODAY()), 3) = 0, MONTH(TODAY()) - 2 &'/01/' &YEAR(TODAY()), FLOOR(MONTH(TODAY()) / 3) * 3 + 1&'/01/' &YEAR(TODAY())),'MM/DD/YYYY')),3,'months'),-1,'day')),
DATETIME_DIFF({Check out date},DATETIME_PARSE(DATETIME_FORMAT(IF(MOD(MONTH(TODAY()), 3) = 0, MONTH(TODAY()) - 2 &'/01/' &YEAR(TODAY()), FLOOR(MONTH(TODAY()) / 3) * 3 + 1&'/01/' &YEAR(TODAY())),'MM/DD/YYYY')),'days')/30,
IF(AND({Check in date}>DATETIME_PARSE(DATETIME_FORMAT(IF(MOD(MONTH(TODAY()), 3) = 0, MONTH(TODAY()) - 2 &'/01/' &YEAR(TODAY()), FLOOR(MONTH(TODAY()) / 3) * 3 + 1&'/01/' &YEAR(TODAY())),'MM/DD/YYYY')), {Check out date}<=DATEADD(DATEADD(DATETIME_PARSE(DATETIME_FORMAT(IF(MOD(MONTH(TODAY()), 3) = 0, MONTH(TODAY()) - 2 &'/01/' &YEAR(TODAY()), FLOOR(MONTH(TODAY()) / 3) * 3 + 1&'/01/' &YEAR(TODAY())),'MM/DD/YYYY')),3,'months'),-1,'day')),
DATETIME_DIFF({Check out date},{Check in date},'days')/30,
IF(AND({Check in date}<=DATETIME_PARSE(DATETIME_FORMAT(IF(MOD(MONTH(TODAY()), 3) = 0, MONTH(TODAY()) - 2 &'/01/' &YEAR(TODAY()), FLOOR(MONTH(TODAY()) / 3) * 3 + 1&'/01/' &YEAR(TODAY())),'MM/DD/YYYY')),{Check out date}>DATEADD(DATEADD(DATETIME_PARSE(DATETIME_FORMAT(IF(MOD(MONTH(TODAY()), 3) = 0, MONTH(TODAY()) - 2 &'/01/' &YEAR(TODAY()), FLOOR(MONTH(TODAY()) / 3) * 3 + 1&'/01/' &YEAR(TODAY())),'MM/DD/YYYY')),3,'months'),-1,'day')),
DATETIME_DIFF(DATEADD(DATEADD(DATETIME_PARSE(DATETIME_FORMAT(IF(MOD(MONTH(TODAY()), 3) = 0, MONTH(TODAY()) - 2 &'/01/' &YEAR(TODAY()), FLOOR(MONTH(TODAY()) / 3) * 3 + 1&'/01/' &YEAR(TODAY())),'MM/DD/YYYY')),3,'months'),-1,'day'),DATETIME_PARSE(DATETIME_FORMAT(IF(MOD(MONTH(TODAY()), 3) = 0, MONTH(TODAY()) - 2 &'/01/' &YEAR(TODAY()), FLOOR(MONTH(TODAY()) / 3) * 3 + 1&'/01/' &YEAR(TODAY())),'MM/DD/YYYY')),'days')/30,
IF(AND({Check in date}>DATETIME_PARSE(DATETIME_FORMAT(IF(MOD(MONTH(TODAY()), 3) = 0, MONTH(TODAY()) - 2 &'/01/' &YEAR(TODAY()), FLOOR(MONTH(TODAY()) / 3) * 3 + 1&'/01/' &YEAR(TODAY())),'MM/DD/YYYY')),{Check out date}>DATEADD(DATEADD(DATETIME_PARSE(DATETIME_FORMAT(IF(MOD(MONTH(TODAY()), 3) = 0, MONTH(TODAY()) - 2 &'/01/' &YEAR(TODAY()), FLOOR(MONTH(TODAY()) / 3) * 3 + 1&'/01/' &YEAR(TODAY())),'MM/DD/YYYY')),3,'months'),-1,'day'),
{Check in date}<=DATEADD(DATEADD(DATETIME_PARSE(DATETIME_FORMAT(IF(MOD(MONTH(TODAY()), 3) = 0, MONTH(TODAY()) - 2 &'/01/' &YEAR(TODAY()), FLOOR(MONTH(TODAY()) / 3) * 3 + 1&'/01/' &YEAR(TODAY())),'MM/DD/YYYY')),3,'months'),-1,'day')),
DATETIME_DIFF(DATEADD(DATEADD(DATETIME_PARSE(DATETIME_FORMAT(IF(MOD(MONTH(TODAY()), 3) = 0, MONTH(TODAY()) - 2 &'/01/' &YEAR(TODAY()), FLOOR(MONTH(TODAY()) / 3) * 3 + 1&'/01/' &YEAR(TODAY())),'MM/DD/YYYY')),3,'months'),-1,'day'),{Check in date},'days')/30,0
))))))
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.