Apr 14, 2020 06:32 AM
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?
!
Solved! Go to Solution.
Apr 14, 2020 09:48 AM
Hi @Victor_Miranda,
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
Apr 14, 2020 09:48 AM
Hi @Victor_Miranda,
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
Apr 14, 2020 12:57 PM
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!!!
Apr 14, 2020 03:42 PM
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!!!
Apr 14, 2020 09:16 PM
Glad i can help :slightly_smiling_face:
Add date 1 too , cant see it in your final formula