9

I am having an issue trying to change to a historical version on an SDE feature class using Python and arcpy.ChangeVersion_management.

I am able to manually change the version to a specific date and time using ArcMap. I am also able to fully automate the process using ModelBuilder.

When I export the ModelBuilder model to a python script the script runs without error but the version that is selected is the historical version with todays date and not the date selected as the date parameter.

Using Arcmap and the Python window (Geoprocessing -> Python) I can also run the python code without error and the result is the same. The historical layer is selected with the current date and not the date selected as the date parameter.

Here is the Python syntax I am executing:

arcpy.ChangeVersion_management("Parcels", "HISTORICAL", "", "7/1/2013 4:30:00 PM")

I also get the same results using:

historyDate = datetime.datetime(2011, 7, 1)
arcpy.ChangeVersion_management("Parcels", "HISTORICAL", "", historyDate)

while the following throws a RuntimeError:

historyDate = datetime.date(2011, 7, 1)
arcpy.ChangeVersion_management("Parcel", "HISTORICAL", "", historyDate)

Is this a known bug or am I just going about this the wrong way?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jun 27, 2014 at 19:01
4
  • My guess is that there is a problem with how you define the date. The tool's parameter expect the value to be a Date object, not a String (resources.arcgis.com/en/help/main/10.2/index.html#//…). There is a helpful Esri forums post on this: forums.arcgis.com/threads/… Commented Jun 30, 2014 at 10:05
  • The line of code was generated from the ArcGIS Model Builders export to Python Script menu command. I changed the python code to use a Date object and the results are the same. The work around from the provided post is to have the end user start with the historical version and then use the function to change to the current version. This workaround won't work for me due to the fact I am scripting the entire process and the historical date comes from a SQL query. Commented Jun 30, 2014 at 12:55
  • 1
    I understand. You should probably contact Esri Tech Support then. I was not able to get this thing working with arcpy on 10.2.2 either. You could publish your code, though in the question body since it is unclear in what format you get your date object and how you supply this parameter to the ChangeVersion tool. My gut feeling is that we either cannot figure out a right way to supply the date object to the tool (I've used script tool GUI for that, parameter of Date type) or there is a bug with this tool. Commented Jun 30, 2014 at 14:42
  • 2
    Alex, thanks for taking the time to look at this. Looks like contacting Esri Tech Support is my next step. I will update the question when I get a response from them. Commented Jul 1, 2014 at 12:44

1 Answer 1

6
+50

After some further research I have confirmed that this is a known bug. Hopefully adding this information here will save someone some time in the future as it was not easy to find using Google or the Esri site.

Bug NIM-087927
Submitted: Jan 8, 2013
Status: Open
http://support.esri.com/en/bugs/nimbus/TklNMDg3OTI3

answered Jul 7, 2014 at 15:52

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.