You need to sign in to do that
Don't have an account?
Gwirizanani Sinoia
Compare 5 date values against each other to which one is current
Hi all,
I am in the process of building a trigger that compares 6 date values on an object against each other to see which one is current. What is the most effecient way to do this? The aim is to ensure that no value is left out in the logic.
Thanks in Advance
I am in the process of building a trigger that compares 6 date values on an object against each other to see which one is current. What is the most effecient way to do this? The aim is to ensure that no value is left out in the logic.
Thanks in Advance
"which one is current" what does that mean? There is a reference date range? (min date, max date, equals to current day? contained in a interval)
You should give an example.
Date 1 = 20/02/2018
Date 2 = 17/02/2018
Date 3 = 02/01/2018
Date 4 = 23/06/2018
Date 5 = 30/02/2018
Date 6 = 10/04/2018
The Idea is to check which is current among the 6 dates. The date range is random all depends on when they were last updated. Hope this makes sense. Finally when the current date is found populate the UpdateDate Field with the value from the 6 date fields.
You don't explain the rule for choosing one date among the six shown above.
What date is current for you? The current date is today and so none of your six dates is "current".
Many people could help here but your explanation is not clear so no one help you until now.
Dictionary: current (adjective): belonging to the present time; happening or being used or done now.
None of your six dates is current (means 12/10/2018 = 12 october 2018 = Today).
In Apex, you just store your values into a Set (if you want just to know that at least, one date is current) or a Map (if you want to know what date is current) and you use contains (Set) or containsKey (Map). But for only 6 values, it is a complication instead of comparing the six values with the current date using simple IF directly.
With a formula, you can use some nested IF. You will not do a dichotomic search with a formula.