Hi,
I have a formula that currently works 90% of the time which finds the number of days between a date range for a given month. The issue is, when the end date, ends in the month I am looking for, example below Oct the formula is correct (row 1, 3 and 4 in the image below). However, when the end date includes BUT does not end in the given month (example: row 2 or 5 in the image below) I get 30 days. I want it to show as 31 days because the date range is inclusive of Oct 2024. Any suggestions?
Here is the formula,
IF(
AND({Start Date}, {End Date}),
IF(
AND(
{Start Date} <= DATETIME_PARSE("10/31/2024"),
{End Date} >= DATETIME_PARSE("10/01/2024")
),
DATETIME_DIFF(
DATETIME_PARSE(MIN(VALUE(DATETIME_FORMAT({End Date}, "X")), VALUE(DATETIME_FORMAT(DATETIME_PARSE("10/31/2024"), "X"))), "X"),
DATETIME_PARSE(MAX(VALUE(DATETIME_FORMAT({Start Date}, "X")), VALUE(DATETIME_FORMAT(DATETIME_PARSE("10/01/2024"), "X"))), "X"),
"days"
) + (MONTH({End Date}) = 10),
0
)
)