I am storing some records in a database. A record has a ‘last visited’ field which is a timestamp. If a record has not been visited yet, the timestamp is invalid. I am currently storing a future date e.g. ‘2101-01-01 00:00:00’ in the ‘last visited’ field, to denote an invalid date.
Is there a better way to indicate an ‘invalid’ date. What is the recommended ‘best practise’ for doing this?
I am using MySQL, but ideally, the recommendation should be db agnostic
Store a NULL value instead. MySQL timestamps are pretty screwed up, so you might need to change your table schema to encourage it to let you put a NULL in there; I use DATETIME instead, it’s a little less weird than TIMESTAMPs in MySQL.