5 DATES compare with today

Hello, forgive my English, I’m Brazilian and I’m having difficulties with the use of the IF command.

First, I have 5 different dates, which I will use as a review in the studies, and I needed to compare all these dates at once with the current day, so if date 1 is less than today, date 1 would return to me, if it were bigger i would return date 2, however, if date 2 was smaller, i would return date 3, and so on.

Does anyone have any idea how to do this?

!

Hi @Victor_Miranda,

Welcome to Airtable Community! :smiley:

First of all, your English is fine , no worries there!

So tell me, are the dates in 5 different fields? If so, then you need something like

IF(Datetime_diff(Today(), {Date 1}, 'days')<0, {Date 1}, IF(Datetime_diff(Today(), {Date 2}, 'days'), {Date 2}))

Is that what you are looking for?

BR,
Mo

1 Like

Hello Mohamed, thank you for answering me, the code you sent me worked very well for the first 3 dates, now my question would be how to add the other two.

Answering your question, yes, the dates are in different fields. I tried to increase the code as shown below but it didn’t work.

IF(DATETIME_DIFF(TODAY(), {R - 2}, ‘days’)<0, {R - 2}, IF(DATETIME_DIFF(TODAY(), {R - 2}, ‘days’), {R - 3})
IF(DATETIME_DIFF(TODAY(), {R - 3}, ‘days’), {R - 4})
IF(DATETIME_DIFF(TODAY(), {R - 4}, ‘days’), {R - 5}))

Since {R - x} is the date that number x, do you have any idea what I did wrong?

Again, THANKS for the awnser!!!

Heyyy, realy thanks, changing the code i have sucess.

IF(DATETIME_DIFF(TODAY(), {R - 2}, ‘days’)<0, {R - 2}, IF(DATETIME_DIFF(TODAY(), {R - 3}, ‘days’)<0, {R - 3}, IF(DATETIME_DIFF(TODAY(), {R - 4}, ‘days’)<0, {R - 4}, IF(DATETIME_DIFF(TODAY(), {R - 5}, ‘days’)<0, {R - 5} ))))

This what i do, thankyou ! realy!!!

1 Like

Glad i can help :slight_smile:

Add date 1 too , cant see it in your final formula

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.