I have a base to manage my vendor payments, and a table that warehouses the vendors’ contracts and payment terms. In that contract table, I’d like to make a formula field that returns the next date when I should expect an invoice, depending on the payment terms (in this table, that is a single-select field titled “Invoice Schedule”).
One of the “Invoice Schedule” options is “monthly,” meaning the formula field I am trying to make should just return the last day of the month (preferably month-over-month, as several contracts are long term).
Here’s how I’ve set up that part of the formula - AT accepts the formula, but returns only blank values. I think that I’m misusing or misunderstanding SWITCH() - wondering if anybody can advise on what I’m doing incorrectly here? Also definitely feels like I’ve overcomplicated this solution but was the best I could figure out, so super open to more elegant solves if you’ve got them!
IF(
{Invoice Schedule} = "monthly",
SWITCH(
MONTH(TODAY()),
"1", DATETIME_FORMAT(DATETIME_PARSE("1/31/" & YEAR(TODAY())), "MM/DD/YY"),
"2", DATETIME_FORMAT(DATETIME_PARSE("2/28/" & YEAR(TODAY())), "MM/DD/YY"),
"3", DATETIME_FORMAT(DATETIME_PARSE("3/31/" & YEAR(TODAY())), "MM/DD/YY"),
"4", DATETIME_FORMAT(DATETIME_PARSE("4/30/" & YEAR(TODAY())), "MM/DD/YY"),
"5", DATETIME_FORMAT(DATETIME_PARSE("5/31/" & YEAR(TODAY())), "MM/DD/YY"),
"6", DATETIME_FORMAT(DATETIME_PARSE("6/30/" & YEAR(TODAY())), "MM/DD/YY"),
"7", DATETIME_FORMAT(DATETIME_PARSE("7/31/" & YEAR(TODAY())), "MM/DD/YY"),
"8", DATETIME_FORMAT(DATETIME_PARSE("8/31/" & YEAR(TODAY())), "MM/DD/YY"),
"9", DATETIME_FORMAT(DATETIME_PARSE("9/30/" & YEAR(TODAY())), "MM/DD/YY"),
"10", DATETIME_FORMAT(DATETIME_PARSE("10/31/" & YEAR(TODAY())), "MM/DD/YY"),
"11", DATETIME_FORMAT(DATETIME_PARSE("11/30/" & YEAR(TODAY())), "MM/DD/YY"),
"12", DATETIME_FORMAT(DATETIME_PARSE("12/31/" & YEAR(TODAY())), "MM/DD/YY")
)
)