Select to view content in your preferred language

Issue using date as an inline variable substituion in ModelBuilder

126
1
a week ago
KatieSelfEd
New Contributor III

I'm using ModelBuilder to iterate through a number of point features, extracting a date from each using 'Get Field Value'. The select tool is then used to select features from another dataset, which have a date on or before the date extracted from the current point. Both date fields are formatted in the format DD/MM/YYYY.

My issue lies with the comparison I'm using in the select tool. From other posts I've seen it seems that Get Field Value treats the output of the iterated field as a string, even if the data type is set to date. To allow for this, I've used the following expression in the select:

AddedDate <= CAST('%pointDate%' AS DATE)

This seems to work for the majority of cases, however I've noticed a discrepancy in my outputs that seems to arise be due to a clash between the US and UK date formating. It seems some points are erroneously selecting some polygons because although the polygons start date is later when read as DD/MM/YYYY, it occurs before if the same string is read as MM/YY/DDDD. (i.e. a point with a 12th January date is being interpreted as being 1st December). Can someone help me to address this?

Screenshot 2024-06-19 164014.png

Screenshot 2024-06-19 163955.png

  

1 Reply
KatieSelfEd
New Contributor III

Quick follow-up to add: I've found a workaround. Changing my system time format to US (which then changed the ArcPro format) seems to have resolved the behaviour. But I would appreciate a coded solution if possible!

0 Kudos