esriFieldTypeDate Conversion to String or Date
When published, the resultant date field becomes a esriFieldTypeDate. But when I query the rest point, the values I get are:
AccDate: 1207872000000 !!!!!!
So in my workflow, I have a form that uses a date picker to have my client select a "FromDate" and "ToDate" to create a range. I'm trying to get my querytask to work, but can't get this date value to convert properly.
"ACCDATE > '" & CDate(FromDate) & "' And ACCDATE < '" & CDate(ToDate) & "'"...... this line generates an error
My variable for FromDate or ToDate are set to strings.
Does anyone have a clue on how this can be solved?
Walter
-
The value returned by the REST endpoint is in 'ticks', IIRC, the number of milliseconds since 1-1-1970. By default this value is UTC, so you may have to deal with a time offset and/or DST.
The where clause is something different. This used to be database dependent, so if for instance the backend is Oracle, you would need something like "ACCDATE > to_date('20140709', 'YYYYMMDD')", for other types of database you would need other date formats. Now with AGS 10.2 there's a new standardized query format which for dates supports this: "ACCDATE > date '2014-07-09'". See here for details: http://resources.arcgis.com/en/help/main/10.2/index.html#/Supported_SQL_functions_in_ArcGIS_Server/015400000686000000/
BTW an (arguably) more readable way to write such strings, which reduces the number of quotes and ampersands, is String.Format("ACCDATE > date '{0:yyyy-MM-dd}' AND ACCDATE < date '{1:yyyy-MM-dd}'", FromDate, ToDate)
0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
1 Kommentar