Define the decision and input records
The fixture accepts date-only YYYY-MM-DD strings. First check the shape, then normalise with SQLite date using a zero-day modifier and compare the result with the original. Shape alone would accept 2026-02-30. A NULL date result also fails; a NULL comparison by itself would not pass a WHERE filter.
All records below are synthetic. Create these tables in a fresh SQLite database before running the read-only query. Quantities are units; monetary values are integer HKD cents, so divide by 100 when presenting HK dollars.
| id | business_date |
|---|---|
| 1 | 2026-10-01 |
| 2 | 03/04/2026 |
| 3 | NULL (unknown or absent) |
| 4 | 2026-02-30 |
CREATE TABLE import_rows(id INTEGER PRIMARY KEY, external_id TEXT, email TEXT, amount_cents INTEGER, business_date TEXT);
CREATE TABLE sync_attempts(id INTEGER PRIMARY KEY, external_id TEXT, outcome TEXT);
CREATE TABLE target_records(id TEXT PRIMARY KEY, external_id TEXT UNIQUE);
INSERT INTO import_rows VALUES (1,'X1','a@example.test',10000,'2026-10-01'),(2,'X2',' ',20000,'03/04/2026'),(3,'X3',NULL,NULL,NULL),(4,'X4','d@example.test',0,'2026-02-30');
INSERT INTO sync_attempts VALUES (1,'X1','success'),(2,'X2','success'),(3,'X3','failed');
INSERT INTO target_records VALUES ('T1','X1');Run the query and compare the result
SELECT id,business_date FROM import_rows
WHERE business_date IS NULL
OR business_date NOT GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]'
OR date(business_date,'+0 days') IS NULL
OR date(business_date,'+0 days')<>business_date
ORDER BY id;| id | business_date |
|---|---|
| 2 | 03/04/2026 |
| 3 | NULL (unknown or absent) |
| 4 | 2026-02-30 |
03/04/2026 is rejected because its day/month meaning is not declared; row 3 is missing a date; 2026-02-30 normalises to another day and is rejected. 2026-10-01 remains valid. Ask the source owner to supply the intended date instead of silently changing an impossible date.
Apply the result within its limits
Executed in the bundled SQLite runtime; this is not a tested PostgreSQL, spreadsheet-serial or timestamp parser. Configure business year bounds separately. Timezones and date-times need their own documented import policy.
The supplied setup and result were executed with SQLite. Adapt the schema and status rules to a test copy of your system, then agree the expected result with the process owner. These examples have not been tested on other database platforms.