# 5 DATES compare with today

Topic Labels: Formulas
Solved
1301 4
cancel
Showing results for
Did you mean:
5 - Automation Enthusiast

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?

!

1 Solution

Accepted Solutions
13 - Mars

Welcome to Airtable Community! :grinning_face_with_big_eyes:

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

4 Replies 4
13 - Mars

Welcome to Airtable Community! :grinning_face_with_big_eyes:

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

5 - Automation Enthusiast

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!!!

5 - Automation Enthusiast

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!!!