0

I am trying to get the next year's closedate using this formula.

IF(
    MONTH(CloseDate) = 2 && DAY(CloseDate) = 29,
    DATE(YEAR(CloseDate) + 1, 2, 28),
    DATE(YEAR(CloseDate) + 1, MONTH(CloseDate), DAY(CloseDate)) – 1
)

There is a syntax error in this case. Can I get a help?

Use formula syntax: Enclose text and picklist value API names in double quotes : ("the_text"), include numbers without quotes : (25), show percentages as decimals: (0.10), and express date calculations in the standard format: (Today() + 7)

Also if this works I have to replace it by current date. So I can use today and get the next year's current date: 12/1/2024

4
  • Hi and welcome to SFSE. Please edit your question to include the syntax error detail.
    – Phil W
    Commented Jan 12, 2023 at 10:07
  • @PhilW Updated qn
    – Sandeep
    Commented Jan 12, 2023 at 10:09
  • I'm assuming this is referencing the Opportunity object's CloseDate?
    – Phil W
    Commented Jan 12, 2023 at 10:18
  • @PhilW Yes exactly.
    – Sandeep
    Commented Jan 12, 2023 at 10:34

1 Answer 1

0

This formula would be better handled simply using:

ADDMONTHS(CloseDate, 12)

As per the documentation:

Returns the date that is the indicated number of months before or after a specified date. If the specified date is the last day of the month, the resulting date is the last day of the resulting month. Otherwise, the result has the same date component as the specified date.

Thus, you don't need to worry about 29th February since this is already handled for you.

1
  • Thanks it worked.
    – Sandeep
    Commented Jan 12, 2023 at 12:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .