Formulas and Functions

Formulas and Functions

Ask for help with your formula and find examples of how others use formulas and functions to solve a similar problem.

Formula to calculate 30 days before

✭✭
edited 09/26/24 in Formulas and Functions

Hi, I have a column with a Partner Due Date (manually entered), and a column with an Internal Due Date (column formula). I would like for the Internal Due Date to be 30 days before the Partner Due Date and am using this formula:

=DATE(YEAR([Partner Due Date]@row), MONTH([Partner Due Date]@row) - 1, DAY([Partner Due Date]@row))

For any Partner Due Dates that are January, I am getting an #INVALID VALUE error. Any suggestions for how to fix this formula so that January Internal Due Dates are December? Thank you!

image.png

Best Answer

  • ✭✭✭✭✭✭
    edited 09/26/24 Answer ✓

    @alys If you literally want the internal due date to be 30 days prior to the partner due date, then you can just use:

    =[Partner Due Date]@row - 30

    However, it looks like what you really want is the same day of the month, but one month prior. If so, try this:

    =IFERROR(IF(MONTH([Partner Due Date]@row) > 1, DATE(YEAR([Partner Due Date]@row), MONTH([Partner Due Date]@row) - 1, DAY([Partner Due Date]@row)), IF(MONTH([Partner Due Date]@row) = 1, DATE(YEAR([Partner Due Date]@row) - 1, MONTH([Partner Due Date]@row) + 11, DAY([Partner Due Date]@row)))), "")

    The IFERROR is there just in case there are any blank partner due dates.

Answers

  • ✭✭✭✭✭✭
    edited 09/26/24 Answer ✓

    @alys If you literally want the internal due date to be 30 days prior to the partner due date, then you can just use:

    =[Partner Due Date]@row - 30

    However, it looks like what you really want is the same day of the month, but one month prior. If so, try this:

    =IFERROR(IF(MONTH([Partner Due Date]@row) > 1, DATE(YEAR([Partner Due Date]@row), MONTH([Partner Due Date]@row) - 1, DAY([Partner Due Date]@row)), IF(MONTH([Partner Due Date]@row) = 1, DATE(YEAR([Partner Due Date]@row) - 1, MONTH([Partner Due Date]@row) + 11, DAY([Partner Due Date]@row)))), "")

    The IFERROR is there just in case there are any blank partner due dates.

  • ✭✭✭✭✭✭

    @alys Happy to help! 😊

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!

Trending in Formulas and Functions