I want to create a unique ID field for each row of data based on the created_date and OBJECTID. For example, if a sample of data had a created_date on 4/28/17 and an OBJECTID of 1, than I would want the unique ID field to be 20170428-1.

I believe I first have to convert the created_date field to string, and then concatenate the date (string) field with OBJECTID. I am using ArcGIS Online's Expression Builder to do this.

In order to convert created_date to string, I have tried using the CAST function, but that does not work. I have also tried to use the EXTRACT function to extract the year, month, and day from the date in order to combine them, but I can only extract one portion of the date (ex: just the year).

Would the Convert Time Field tool be of use to me?


Unfortunately, there is no function for converting the number to string available in Expression Builder window in ArcGIS Online map viewer. The CAST function operates only on integers making it possible to convert them to either double or int. There is function for making strings out of integers.

Except for programmatic access to the feature service using FieldCalculator REST operation and Feature Service ApplyEdits REST operation, you have really two options:

  1. Edit your feature service feature layer in ArcMap using functionality that comes with the Field Calculator in ArcMap.

Running this code

arcpy.time.ParseDateTimeString( !CustomDate! ).strftime('%Y%m%d') + '-' + str( !OBJECTID!)

would give you:enter image description here

  1. If you don't have ArcGIS Desktop, then create four new fields of String type (three for year, month, date values and one for ObjectID field) and use the CONCAT(string1, string2) function to get your strings together.

So, you would use


The final calculation would be:

CONCAT((CONCAT((StringYear + StringMonth + StringDay), '-')), StringObjectId)
  • I was able to calculate the CollectionID in ArcGIS Online using the calculations you provided in option 2 above. Thank you so much, this really helped me in a time crunch. – Adam Wysocki May 1 '17 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.