SQLite Forum

Best practice: Save partial dates
Login
If the task is to use one TEXT column to save as much information as available (only year of birth, but not the day, or day but not the year), then any placeholder will work but might affect ordering when sorting:

2021-06-29 versus XXXX-06-XX, which of them you want to be before which?

If you have partial or full information and intend to search separately by year, or month or day (select all people born on a 29th), then create three separate columns for year, month and day and indexes for each. Some will have NULLs.

Enforcing date format using CHECK() will be more involved with the placeholders. Without them:

CREATE TABLE a(visitDate TEXT CHECK( date(visitDate) = visitDate OR visitDate IS NULL))