ThinkGeo.com    |     Documentation    |     Premium Support

Returned Date not valid

I’m upgrading my code to use ThinkGeo v12.3.2. I’ve hit a snag with a date field in a FileGeoDatabase. This code worked fine previously but now it is not returning a value that I can turn into a date. What options do I have to get a correct date value?

Here is the code:
String sourceGDB = “F:\Temp1\Alabama.gdb”;
String gdbTable = “Alabama”;
FileGeoDatabaseFeatureLayer fileLayer = new FileGeoDatabaseFeatureLayer(sourceGDB);
fileLayer.ActiveLayer = gdbTable;
fileLayer.Open();

Collection features = fileLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns);
foreach (Feature tempFeature in features)
{
AreaBaseShape tempShape = (AreaBaseShape)tempFeature.GetShape()
Dictionary<String, String> tempColValue = tempFeature.ColumnValues;

When I look at what is in the dictionary the date columns are not right. They look like this:

Name Value Type
[11] {[creation_date, %d-%d-%d-%d-%d-%d]} System.Collections.Generic.KeyValuePair<string, string>
Key “creation_date” string
Value “%d-%d-%d-%d-%d-%d” string
:arrow_forward: Non-Public members
[12] {[last_change_date, %d-%d-%d-%d-%d-%d]} System.Collections.Generic.KeyValuePair<string, string>
Key “last_change_date” string
Value “%d-%d-%d-%d-%d-%d” string
:arrow_forward: Non-Public members

This is what the data looks like:
Screenshot 2021-07-23 112526

Howdy,

Would it be possible you attach a test database? Our test databases don’t seem to have this problem but it could be way our databased had the date encoded. You could possibly just take your existing database and delete all the records but one.

Here is the data. I had to delete some of the columns and scrub some of the data. I left all the date columns and a few others. I also chose a smaller State so it would go faster on my end, but the results are the same. Let me know if you need anything else.NewHampshire.zip (28.5 KB)

Thanks for sharing the data, it really helped. I found the issue was in our string format for the date time. I fixed it by taking the year, month, day etc. values and put them into a DateTime object and then doing .ToString. This creates dates formatted in a way I think you will like. I attached a screenshot showing it working with your dataset. The build process will kick off tonight and you should have a working build on the developer build channel tomorrow morning.

This fixed the issue! Thank you!

Hey @Jeri_Sue_Ponder,

Good to hear! Closing.

Thanks,
Kyle