On 14/8/19 8:33 PM, Clemens Ladisch wrote:
> CREATE TABLE t (
>   date date  CHECK (date = date(date, '+0 days'))
> );

Sadly, this isn't sufficient for guarding against malformed dates like
'2019-02-00' and '2019-02-1' that the OP listed, because the CHECK
expression in those cases resolves to NULL, which does *not* signal a
constraint violation.

Instead, you have to "round-trip" the date conversion manually, and
check that the intermediate Julian conversion IS NOT NULL, for this
CHECK to be truly effective.

-- 
Best Regards,
Adrian

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to