How to compare dates with arcade calculation in Survey123?

107
1
03-27-2020 11:48 PM
Highlighted
New Contributor III

I have a survey which records the date when a record is created.

Would it be possible to somehow have a dynamic field which is parsed at run time to record either a 1 or 0 to see whether the record was made today? Obviously If this was calculated when the record was calculated it would be always 1.

Tags (2)
Reply
0 Kudos
1 Reply
Highlighted
Esri Esteemed Contributor

Hi Robert,

This can be done in a couple of ways.

If you need new records in the past 24 hours, look at the DateDiff function and use a if/else block to assign 1/0 based on that: Date Functions | ArcGIS for Developers 

If you need to match the exact date, I would use the Day(), Month(), and Year() functions to compare the values to today:

var today = Now();
var theDate = Date($feature.CreationDate);

if (Day(today) == Day(theDate) && Month(today) == Month(theDate) &&Year(today) == Year(theDate)) {
return 1;
}

return 0;

Reply
0 Kudos