Converting between Date Formats

Discussion created by sjacksonesriaustralia-com-au-esridist Employee on Jun 24, 2014
Latest reply on Jun 29, 2014 by rsunderman-esristaff
I have an incoming feed which has a LastSampleTime

This comes into GEP and by default creates a string field in the GeoEvent Defintion.

1. Incoming Date as a String Field:
"25/06/2014 12:45:00"

If I alter the LastSampleTime in the GeoEvent Definition to be a date:

2. Incoming Date as a Date Field:
'06/25/2014 12:00:00 AM'
- It makes all the times to be 12:00:00 AM, which is incorrect as the times vary on the incoming stream. 

I have a feature service hosted on ArcGIS Online, and I have the rest of the feed readings updating the relevant fields on this service.
As it is ArcGIS Online, I have no control over the underlying DBMS in regards to any settings around date formats.

For the date field, if I pass the date as a date (#2 above), then this gets written to the feature fine.  However, unless I can find a way to ensure the time is correct, this is not going to be an option.

If I try and pass the date as a string, then it won't work.  This makes sense, as if I try and do an ApplyEdits using the string directly against the REST endpoint, then it fails:


This is using the same date (string) that I am getting off the feed:

    "attributes" : {
      "OBJECTID" : 1,
      "LastSampleTime" : '25/06/2014 12:45:00'

Error: 1000, Description: Conversion failed when converting date and/or time from character string.

What does work, is if it convert the date into a different format:


    "attributes" : {
      "OBJECTID" : 1,
      "LastSampleTime" : '2014-06-25 12:45:00'

= Edits applied ok!

I was pondering having a play with a regular expression to try and convert the original date into a date string that works, but sounds like the wrong way to do it.  I dont think there are any function expressions that convert dates into different formats.  

Please, some advice on how to go about getting the correct date & timestamp from the incoming feed into GEP would really help me out.