Skip to content

"2013-03-00" in date column returns "Invalid Date", but value is allowed in MySQL #429

@0b10011

Description

@0b10011

We use "2013-03-00" in a date column to denote books with a publish date in "March 2013" (due to not knowing the specific day, or the day being different depending location). With node-mysql, however, this returns "Invalid Date" (probably due to blindly feeding it into new Date()).

From the manual (source):

MySQL permits you to store dates where the day or month and day are zero in a DATE or DATETIME column. This is extremely useful for applications that need to store birthdates for which you may not know the exact date. In this case, you simply store the date as '2009-00-00' or '2009-01-00'. If you store dates such as these, you should not expect to get correct results for functions such as DATE_SUB() or DATE_ADD() that require complete dates. To disallow zero month or day parts in dates, enable the NO_ZERO_IN_DATE SQL mode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions