[GIS] Why does shapefile’s dbf convert YYYY date to YY-format

datedbfshapefile

I save date from database's timestamp to shapefile date attribute. For example, I took from database [2031,10,31] and set it to '31.10.2031' at shapefile using python's shapefile.py as sh:

self.sh.field('Exp_date', 'D', 10)
....
valueString = date(*tuple(date_value)).strftime('%d.%m.%Y')
print valueString
>>>31.10.2031
self.records.append(valueString)
... # set other fields
self.sh.record(*self.records)

But when I open the result at ArcGIS 10.1 I see all years converting to 1930-2029 (as system Date&Time settings). So when I open the dbf at shapefile directory, I see the DD.MM.YY-format dates. But at DBF specification 'D' fields are YYYYMMDD format.

Is there a way to save full year at dbf?

Best Answer

Unlike a number of data formats of its time, dBase-III was "Y2K" compliant (it used the extra bytes necessary to store the actual year in four digits). Unfortunately for modern uses, this came at the cost of not storing time values at all.

The dBase field buffer for D type values utilizes eight characters, in the format YYYYMMDD (delimiters would have only increased the storage requirement 25%).

It appears that the Python interface you are using does not validate or otherwise enforce proper date value formatting, so you are required to provide the exact date format used in the transfer buffer. In strftime syntax, that would be to use the format string '%Y%m%d'.