Convert stange 3 byte HEX date format from DBF

Viewed 92

I need to work with a DBF file (dBASE III PLUSE, with memo) which contains weirdly formatted date values. The values are saved as HEX numbers counting up for each day.

Now comes the weird part, the counter jumps (compare e.g. integer value) every month one and every year two values. Basically, it counts a 00 month and a 00 day.

EDIT: Further it counts for every month 31 days, e.g. end of February.

EDIT 2: Another strange implementation I didn't see before is, that each byte/hex value count's only until 7F and then the next byte count's up e.g. 2001-02-15 -> 2001-02-16...

HEX         Integer    Date       * not a valid date
====================================================
2E 22 30    3023408    1970-00-00 *
2E 22 31    3023409    1970-01-00 *
2E 22 32    3023410    1970-01-01
2E 22 33    3023411    1970-01-02
2E 22 34    3023412    1970-01-02
[...]
2E 22 50    3023440    1970-01-31
2E 22 51    3023441    1970-02-00 *
2E 22 52    3023442    1970-02-01
[...]
2E 22 6D    3023469    1970-02-28
2E 22 6E    3023470    1970-02-29 *
2E 22 6F    3023471    1970-02-30 *
2E 22 70    3023472    1970-02-31 *
2E 22 71    3023473    1970-03-00 *
2E 22 72    3023474    1970-03-01
[...]
2E 25 30    3024176    1970-12-31
2E 25 31    3024177    1971-00-00 *
2E 25 32    3024178    1971-01-00 *
2E 25 33    3024179    1971-01-01
[...]
2E 7F 7F    3047295    2001-02-15
2F 00 00    3080192    2001-02-16
[...]

With this knowledge, I could generate a list from 1900-01-01 until 2038-01-18, see example.txt.

Is this a known pattern, I just never heard about it?
Is there a simple way to convert date back and forward?


As @js2010 pointed out it's probably the 3 byte Date of last update, in YYMMDD format structure, see dbase.com/Knowledgebase/INT/db7_file_fmt.htm . Though there isn't really a further explanation.

0 Answers
Related