Auto Calculate a Date Field

766
3
11-13-2018 12:39 PM
by Anonymous User
Not applicable

I am trying to automatically calculate a date field. What I would like to do is take a permit date and add 180 days to calculate an expiration date. I added a date field for the final calculation. I open the field calculator and write the expression. The expression verifies correctly but when I calculate the field I get errors. I tried several different calculations to see if any of them would work. Below is an example of a calc I did to extract a date. Again, the expression verified correctly but then this error popped up when I calculated the field.

0 Kudos
3 Replies
MikeMinami
Esri Notable Contributor

From the error message, it appears you're using the extract function. This function, I believe, returns a number. If you are trying to assign this value to a date field, you'll get a field type mismatch of trying to calculate a number into a date field.

If your goal is to simply add 180 days to a date in a field and assign it to another field, you can form an expression like this:

[PermitDate] + 180

Under normal circumstances, this would yield a new date 180 days into the future. HOWEVER, THERE IS A BUG in AGOL with date addition, where it doesn't work. Subtraction, however works. So try this expression

[PermitDate] - -180

Where you subtract negative 180.

Mike

0 Kudos
by Anonymous User
Not applicable

Thank you Mike. Your suggestion of adding a negative did work in Desktop, but it did not work in ArcGIS online. This still solves my problem with the calculation and works for me.

Veronica

0 Kudos
GISAdministrator16
New Contributor

Regarding the bug in AGOL when calculating a date field, I found that when I turned off the sync setting, a calc operation worked properly.  When sync was on, the calc would fail.

--Jeff

0 Kudos