Skip to main content
Solved

Formula that shows "Yes" if date is in the previous year

  • June 4, 2023
  • 2 replies
  • 45 views

Forum|alt.badge.img+3

Hello everyone, 

I have currently the following formula in my table that shows "Yes" if the date in "Fin contrat" is in a future month. I am trying, but with no success, to adapt this formula to show "Yes" in another column if the same date is in the previous year (so currently 2022).

Can someone please help me achieve this?

Thanks! 🙂

 

IF(
IS_AFTER(
{Fin contrat},
DATEADD(
DATEADD(
DATETIME_PARSE(
"01 " & DATETIME_FORMAT(
TODAY(),
"MM YYYY"
),
"DD MM YYYY"
),
"1",
"months"
),
"-1",
"days"
)
),
"Yes",
"No"
)

 

Best answer by Stephen_Orr1

Hi @ClarenceK,

You could adapt this formula to something like:

 

IF( IS_BEFORE( {Fin contrat}, DATETIME_PARSE('1/1/' & YEAR(NOW())) ), 'Yes', 'No' )

 

*but this would be 'yes' for all previous years, not just last year.

If you want to check if a date's year = last year, you could do:

 

IF( YEAR({Fin contrat}) = YEAR(DATEADD(NOW(),-1, 'year')), 'Yes', 'No' )

 

Hope that helps!
-Stephen

2 replies

Forum|alt.badge.img+18
  • Inspiring
  • Answer
  • June 4, 2023

Hi @ClarenceK,

You could adapt this formula to something like:

 

IF( IS_BEFORE( {Fin contrat}, DATETIME_PARSE('1/1/' & YEAR(NOW())) ), 'Yes', 'No' )

 

*but this would be 'yes' for all previous years, not just last year.

If you want to check if a date's year = last year, you could do:

 

IF( YEAR({Fin contrat}) = YEAR(DATEADD(NOW(),-1, 'year')), 'Yes', 'No' )

 

Hope that helps!
-Stephen


Forum|alt.badge.img+3
  • Author
  • New Participant
  • June 4, 2023

Hi @ClarenceK,

You could adapt this formula to something like:

 

IF( IS_BEFORE( {Fin contrat}, DATETIME_PARSE('1/1/' & YEAR(NOW())) ), 'Yes', 'No' )

 

*but this would be 'yes' for all previous years, not just last year.

If you want to check if a date's year = last year, you could do:

 

IF( YEAR({Fin contrat}) = YEAR(DATEADD(NOW(),-1, 'year')), 'Yes', 'No' )

 

Hope that helps!
-Stephen


That's perfect, thank you very much @Stephen_Orr1!