RelativeDate Adjustment for Offset Unit

RelativeDate(Today(), 3) yields the date three months from today. This is great, but could easily be modified to fit more use-cases.

Adding an optional third parameter enables flexibility to adjust by a number of weeks, months, days, or years. By default, the third parameter would be set to a value that maps to months.

Sample of mapping:
0 - years
1 - months (default)
2 - weeks
3 - days

Examples

RelativeDate("1-2-2020", 4) // yields 5-2-2020 (4 months added)
RelativeDate("1-2-2020", 4, 1) // yields 5-2-2020 (4 months added)

RelativeDate("1-2-2020", 4, 0) // yields 1-2-2024 (4 years added)

RelativeDate("1-2-2020", 4, 2) // yields 1-30-2020 (4 weeks added) 

RelativeDate("1-2-2020", 4, 3) // yields 1-6-2020 (4 days added)

// Where this really shines (not sure how chaining would work, so JS notation instead):
RelativeDate(
    RelativeDate(
        RelativeDate(
            RelativeDate( thisRow.date, 3, 3),
        5, 2),
    7, 1),
9, 0);
1 Like