Hey Xander,
Thanks for getting back so quick. I tried that out and got an error that says, "Execution Error:unable to find a number expression in pattern: MM/DD/Y".
I was able to set up another one that worked but it seems to be returning the wrong date. The related record has a date of 9/8/2020 but the expression is returning 8/8/2020. I tried it with a few others and it seemed to always be off by a month. This was the code:
// first read out the ID of the Feature1
var id = $feature.STATE_NAME;
// access the table Feature2
var tbl = FeatureSetByName($map, 'Registration Submissions');
// create a sql expression to query on ID
var sql = "STATE_NAME = '" + ID + "'";
// filter the table using the sql expression
var related_data = Filter(tbl, sql);
// initiate a variable to hold the result
var result = Max(tbl, 'SubmissionDate');
var relateddate = Date(result)
var formatteddate= Month(relateddate)+"/"+Day(relateddate)+"/"+Year(relateddate)
// return the result
return formatteddate;
I'm guessing it's something to do with one of the Date functions. If I have it return 'result', it gives me the number 1599609600000. I checked this on epochconverter.com and it came back as 9/8/2020 at 9:40:47 PM GMT. I tried returning relateddate and that came back as 08 Sep 2020 08:00:00 pm so the date is correct at that point but gets skewed by the Month() function.
Any idea of what might be throwing it off by a month? Is there another way instead of the Month, Day, and Year function to format the date?
Thanks!
Tim