You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CAST of a number to DATETIME or DATE throws a TypeError: CAST(19961121194027 AS DATETIME) #2853
CAST of a number to DATETIME or DATE throws a TypeError. MySQL reads such a number as YYYYMMDDhhmmss or YYYYMMDD.
Seen in the MySQL server tests run (alasql-mysqltest): 12 statements in 6 files, for example SELECT CAST(NULLIF(19961121194027, 0) AS DATETIME) AS dt in func_if.test. Reproduced with alasql 4.21.0:
alasql('SELECT CAST(19961121194027 AS DATETIME) AS d');// TypeError: val.substr is not a functionalasql('SELECT CAST(20200102 AS DATE) AS d');// TypeError: val.substr is not a functionalasql("SELECT CAST('1996-11-21 19:40:27' AS DATETIME) AS d");// works
Expected (MySQL): 1996-11-21 19:40:27 and 2020-01-02. At least an error that says the value is not a date, not a TypeError.
Breaking?
No. Today it throws.
Related: #2804 (CAST to DATE of text gives a two-digit year).
Activity
mateuscmtropical commentedon Nov 11, 2026
Hi, I'd like to work on this one.
mateuscmtropical commentedon Nov 11, 2026
Hi, I've opened a PR for this: #2988