Select to view content in your preferred language

Editing Date in AttributeInspector BUG?

1549
11
11-04-2010 05:08 PM
JoseSousa
Esri Contributor
Dear ArcGIS API for Flex Team,

I've created a simple MXD just with a single layer and field named DATE of type Date.
I've published to MXD as Feature Service.

I'm using your out-of-the-box ArcGIS Web Map Viewer for Flex and the editing widget point to this Uri.

When I create or update features and edit the Date attribute the date that is stored in the database is always one day before the date I have specified. For instance, if I specify 6 of November it will put in the Database 5 of November. I've read your code on the Widget and it references to a bug on REST API.

(your comments on the EditWidget.mxml)
var date:Date = new Date(feature.attributes[field.name]);
if (date.milliseconds == 999)
{
     date.milliseconds++;  //Add 1ms to date values ending in 999 to workaround REST date bug                               
     feature.attributes[field.name] = date.time;
}

I have tested this behaviour with AGS API for Silverlight and it happens the same way.

Our date and time settings are (UTC + 12:00) Auckland, Wellington and I am thinking that the API isn't supported. I hope I am wrong.

Can you provide me a solution or an workaround? This is an important feature.

With regards,
José
Tags (2)
0 Kudos
11 Replies
DasaPaddock
Esri Regular Contributor
This should be fixed in 10.0 SP1. If you load the feature in the REST services directory it should have the correct date. The bug is that when you query the server and in the json response, the value will be (value - 1) which makes it look like it's the previous day if you're only showing the date and the time is 00:00.
0 Kudos
JoseSousa
Esri Contributor
Hi Dasa,

Just to tell you that the bug still exists in AGS10 SP1.
I have even tried with the Javascript API and it is the same. I get the current date and time in miliseconds correctly call the applyEdits and the AttributeInspector shows everything ok. When I query the data using REST it is everything ok as I was expecting. When I go to ArcMap and open the FeatureClass I see that the date is different in exactly 12 hours.

Can you confirm this issue?
José
0 Kudos
DasaPaddock
Esri Regular Contributor
I believe the issue is that the API's are using your computer's local time but ArcMap is using UTC time. This is currently under investigation but one workaround may be to offset the date on the client to compensate for this.
0 Kudos
JoseSousa
Esri Contributor
Hi Dasa,

I had already developed an workaround for this on the client side. It was just to confirm the issue.

Thanks a lot,
José

Eagle Technology (Esri NZ)
0 Kudos
RachelS
Frequent Contributor
Does anyone know has this bug been resolved, as 3 years on I am now having the same problem using the Edit Widget in Flex 3.1 whereby the date is added but is stored in the feature dataset as the previous day.
Surely it has been fixed by now?
0 Kudos
JoseSousa
Esri Contributor
Hi Rachel,

You should try to upgrade your API to the latest one (3.3). Not sure what version of ArcGIS for Server you are using.
If the latest versions of AGS for Server, ArcGIS API for Flex and the ArcGIS Viewer for Flex (in case you are using it) don't solve the issue then you can try to apply the same workaround provided here:
http://gisengineering.blogspot.co.nz/2011_09_01_archive.html

Kind regards,
Jose
ESRI New Zealand
0 Kudos
RachelS
Frequent Contributor
Jose,
Thanks for getting back to me, I am using the latest version of ArcGIS 10.1 service pack 1.
And unfortunately don't have the API, only flexviewer
I can't believe this thread is 3 years old and ESRI haven't fixed this bug!
Do you know of anyway around it in ArcMap like is it possible to create a field that is set to Date +1 day?
I know I can run a calculation on the data but I need it to updateautomatically as soon as the data is entered as staff print forms from the data straight away.
There seems to be very little about this problem in the forums, does it not affect many people? It seems a fundamental problem of ESRI recording incorrect dates, I'm surprised nothing has been done about it.

Rachel
0 Kudos
JoseSousa
Esri Contributor
Hi Rachel,

Apologies for the late response.
I am not sure whether I understood your question appropriately.

I don't recall what were the outcomes of my testing at the time since it was some time ago.

What I believe that is happening is:
1 - When you create data using ArcMap he will convert your local time into UTC and save that value in the geospatial repository.
2 - For display purposes the software will read your local time settings and translate the UTC values into your local time. This means that any application wherever it is located in the world can perform the same exercise.

The problem that it seems to be happening is that the REST API or Flex API from Esri is not converting the values appropriately. I would say that it is the responsibility of the ArcGIS API for Flex to read your local time values and translate seamlessly the UTC values into the appropriate time format.

If the API has a bug (not saying that it still has) then a workaround can be written on top the Flex Viewer that is one layer above the Esri Flex API. Note that the Flex Viewer uses the ArcGIS API for Flex internally.

The workaround is provided in the link I have sent previously.

If the Flex Viewer version that you have is the compiled version than you don't have many automatic options.
Either you build a custom script (e.g. ArcPy) that runs periodically and passes all the new updates to date - 1 day or you write a workaround at the DB level (wouldn't recommend this). An example would be implementing a listener on the RDBMS for catching any CRUD operations and modifying the UTC date time to -1 day automatically. The implication of this is that it makes difficult to upgrade the geodatabase because the script will have to be maintained.

I would suggest that you download the latest Flex Builder from Esri and test to see if the issue still occurs.

http://www.esri.com/apps/products/download/index.cfm?fuseaction=download.main&downloadid=974

Cheers,
Jose
0 Kudos
RachelS
Frequent Contributor
Hi Jose,

I'm using the compiled version of flex, so yes my options are limited, I've logged it with ESRI and he's sent it of to Redlands so we'll see what they come back with.
In the mean time I've worked around it, by created another date field as a string, this means in flex the user has to type the date in rather than using the calender, but it means the correct date is stored and will print out correctly in my forms.
Then every so often I can update the actual date field using field calculator and it registers it as a proper date so I can use this field for querying, sorting etc.
It's a pain I have to do it this way but until ESRI decide to fix the bug, it's my only option.
Thanks
Rachel
0 Kudos