Select to view content in your preferred language

Query Task AMF Date Issue

1204
6
08-20-2010 09:43 PM
RobertScheitlin__GISP
MVP Emeritus
I have just noticed that queries using AMF set to true are returning date fields in UTC seconds and not an actual date object or date string in the API is this a bug?
Tags (2)
0 Kudos
6 Replies
DasaPaddock
Esri Regular Contributor
This is by design in AGS Server 10. The behavior should be the same if you set useAMF to false which causes it to request a JSON response.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Dasa,

   Ok, so why is it not decoded by the API as it is when you query using the service page and have the format equal to html?
0 Kudos
DasaPaddock
Esri Regular Contributor
To post-process the response would add additional overhead looking for all the date fields and new'ing Date objects. Typically an app developer will want to format the date presented to the user, so at that time, they can also first new a Date with the value.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Dasa,

   Ok, so maybe you can help me with my issue then when I query a parcel that has a Sales_Date field of type esriFieldTypeDate it has a value of 11/25/1998 and when it is returned in JSON it is 911952000000. so when I use new Date(value) I get 11/24/1998 instead??? What gives, didn't you just say that developers can simply use new date?
0 Kudos
DasaPaddock
Esri Regular Contributor
The problem can be with the time zone. Trying printing date.toUTCString() vs. date.toString(). You can also check the value of the dateUTC property.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Thanks Dasa,

   toUTCString worked for me.
0 Kudos