# Compare Current Date to Future Date to Display Data ArcGIS Online

629
4
04-07-2020 01:16 PM
MVP Regular Contributor

Hi,

Right now I have polygon data representing ponds in a webmap. Within the polygona data I have an attribute which is the expiry date of the certification for the pond.

What I want to show is the based on the current date (must change daily) is how many months from now till the expiry date exist visually using a 3 color mode:

• expiry within 1 month
• expiry within 3-6 months
• expiry 12 months+

How is this possible? Is an arcade an option?

Thanks

1 Solution

Accepted Solutions
Esri Esteemed Contributor

Hi joe rodmey ,

That is a typical case you could do using Arcade in the symbology.  See the example below:

``````var expdate = \$feature.ExpireDate // change to your field
// var expdate = Date(2021, 1, 1);
var expiremonths = DateDiff(expdate, Today(), "months");

var result = "";
if (expiremonths < 1) {
result = "within 1 month";
} else if (expiremonths < 3) {
result = "within 1-3 months";
} else if (expiremonths < 6) {
result = "within 3-6 months";
} else if (expiremonths < 12) {
result = "within 6-12 months";
} else {
result = "12 months+";
}

return result;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍``````
4 Replies
Esri Esteemed Contributor

Hi joe rodmey ,

That is a typical case you could do using Arcade in the symbology.  See the example below:

``````var expdate = \$feature.ExpireDate // change to your field
// var expdate = Date(2021, 1, 1);
var expiremonths = DateDiff(expdate, Today(), "months");

var result = "";
if (expiremonths < 1) {
result = "within 1 month";
} else if (expiremonths < 3) {
result = "within 1-3 months";
} else if (expiremonths < 6) {
result = "within 3-6 months";
} else if (expiremonths < 12) {
result = "within 6-12 months";
} else {
result = "12 months+";
}

return result;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍``````
MVP Regular Contributor

Thanks Xander Bakker!

Just 2 questions. Wouldn't there be a stop limit? By this I mean should there a limit to the say the "within 1-3 months" category that not only has ❤️ but a condition to not capture anything less than 1 month or the else if handles that?

Also how does DateDiff() do its comparison? When it looks at months is it looking at the particular dates that are passed in (For example May 8 expiry with April 8 current date) or is it just comparing month of April with month of May and saying that's 1 month difference regardless of the exact day in the month?

I would also like to only have the expiry within 1-3 months and not expiry less than 1 month. For that category I only need to see everything that is expiring from today to 3 months out.

Esri Esteemed Contributor

Hi joe rodmey ,

Wouldn't there be a stop limit? By this I mean should there a limit to the say the "within 1-3 months" category that not only has ❤️ but a condition to not capture anything less than 1 month or the else if handles that?

The validation starts with the first condition and if the value is less than 1, it will stop at the first condition. In case it does not match the condition it starts with the second. This way the classification is done correctly.

Also how does DateDiff() do its comparison? When it looks at months is it looking at the particular dates that are passed in (For example May 8 expiry with April 8 current date) or is it just comparing month of April with month of May and saying that's 1 month difference regardless of the exact day in the month?

Have a look at the expression below:

``````var expdate = Date(2020, 4, 10);
var expiremonths = DateDiff(expdate, Today(), "months");
return expiremonths;‍‍‍``````

Note that the month "4" is a value from 0 to 11, so 4 represents May in this case. The result is a decimal value: 1.064516129032258. So, it takes to dates and returns the difference in decimal months in this case.

I would also like to only have the expiry within 1-3 months and not expiry less than 1 month. For that category I only need to see everything that is expiring from today to 3 months out.

In that case you can remove the first condition:

``````var expdate = \$feature.ExpireDate // change to your field
var expiremonths = DateDiff(expdate, Today(), "months");

var result = "";
if (expiremonths < 3) {
result = "within 3 months";
} else if (expiremonths < 6) {
result = "within 3-6 months";
} else if (expiremonths < 12) {
result = "within 6-12 months";
} else {
result = "12 months+";
}

return result;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍``````
MVP Regular Contributor

Thanks