Date-Range Domains - what gives

1553
2
05-29-2018 04:52 PM
JohnMDye
Occasional Contributor III

Could use some help understanding Range Domains configured to use the 'Date' field type.

Step 1. In ArcGIS Pro, I created a new Range Domain in a file gdb configured to use the Date field type.

fgdb = r"C:\Users\johnmdye\Documents\ArcGIS\Projects\MyProject.gdb"
arcpy.CreateDomain_management(
    fgdb, 
    'DateDomain', 
    'My Date-Range Domain', 
    'DATE', 
    'RANGE')‍‍‍‍‍‍‍‍‍

Step 2. Next, I set the Range Domain values. I checked the documentation to see how I needed to format the date inputs but there was no information about formatting dates or passing in a date-time object. All of the examples showed text inputs only.

arcpy.SetValueForRangeDomain_management(
    fgdb,
    'DateDomain',
    '01/01/1980 12:00 AM',
    '05/29/2018 12:00 AM')‍‍‍‍‍‍‍‍‍‍

When I checked the domain after running this, the time had automagically been set to 12:00am for both the minimum and maximum value. This made me assume that ArcGIS Pro had successfully converted my input strings for the min and max parameters to date-time objects.

Step 3. Next, I assigned the domain to a field

table = r"C:\\Users\johnmdye\Documents\ArcGIS\Projects\MyProject.gdb\TEST"
arcpy.AssignDomainToField_management(
    table, 
    'DateField',
    'DateDomain') ‍‍‍‍‍

After that successfully completed, I tried to edit the 'DateField' with the 'DateDomain' assigned to ensure that I could only specify a date between the min and max range, but I was able to enter any date I wanted and save the table. 

I then tried performing the workflow completely through the Pro UI and discovered that after I'd created the 'DateDomain' domain manually, I couldn't assign it to my 'DateField' through the Pro UI. (The circles are my mouse clicks)

So, in this case I jumped back to Step 2 above and executed the SetValueForRangeDomain_management tool to set 'DateDomain' on 'DateField' and it worked, or at least didn't return an error and when I looked at the Field Design for the TEST table, 'DateDomain' was indeed showing as being assigned to 'DateField'.

So, then I added 'TEST' table to a new map and attempted to edit the 'DateField' for a record. Lo and behold, I could enter any date I wanted and save the table. 

I shouldn't be able to set the date to 5/30/2018 because the maximum value on the DateDomain which is assigned to the DateField is '5/29/2018 12:00 AM'

What gives?! Am I doing something wrong? Can anyone else replicate this odd behavior?

0 Kudos
2 Replies
RandyBurton
MVP Alum

I have noticed a similar issue with 10.5 desktop.  I performed a test using a range domain on fields of type Long Integer and Date.  Editing a file geodatabase inside ArcMap, I could set the fields to a value outside the range.

0 Kudos
blackcloud77
New Contributor

My experience is that the use of domains will not prohibit the entry of data that does not conform to the configured domains.  You can calculate the fields to whatever you want; or enter the nonconforming data manually.  I think domains are more for convenience and promoting consistency when users are editing data with less sophisticated tools, such as web maps and mobile apps.  They certainly do not enforce data consistency. 

0 Kudos