If you change *anything* in a file of record - Pascal record structure - it is no longer compatible with your old data!!! That would be silly to expect otherwise.
?? Why would it be 'silly' to expect fields in a fully structured 'Record' to be held in anything other than the order that they are declared? I don't use 'Packed' Records specifically to avoid such potential issues. I have used this concept for many years making sure that any adjustment maintains the exact number of bytes in exactly the same position in the record; and it has not caused me any problem previously.
Also, if you use a file of record make sure the datetime is simply stored as a TDateTime.
Also make sure that it gets updated on every write, like a database would do on its timestamp.
Again, although I do use TDateTime on occasion, where it is appropriate to use only d.m.y, I have my own 'Date' Type, which is a record with two bytes (d [1..31] & m[1..12]) and a word (a 4 digit year) - I never did fall foul of the 'Millenium bug' 😱
The dates in this database are not 'volatile', though they may be incomplete - ie. only the year known/estimated - and they can be entered in a variety of formats (with '
/' or '
-' as separators) or even as fully detailed text format (3rd Oct 2026) but they are always stored as d, m & y. In the case of 'approximate' Dates
(ie. year only estimated) then I store the 'day' as 126,
(the tilde, '~' is chr 126) which is used as a 'flag' to circumvent the normal checking & formatting process - the 'month' as zero, and the assumed 'year' in full. Once entered, the only reason to ever 'update' them is if new information comes to light which invalidates the recorded data and then of course the data is updated, just as any other information would be. There is no need for a 'TimeStamp' within the record.
I could potentially understand some 'corruption' of Fields beyond the modified Field if I had inadvertantly mis-calculated the number of bytes used by the original fields (or the replacement) - or if there was some 'padding' that I wasn't aware of - but this corruption was to ALL fields - the change was to the tenth field of 19.