All:

According to the MySQL manual:

"STR_TO_DATE()

This is the inverse of the DATE_FORMAT() function. It takes a string str and a format string format. STR_TO_DATE() returns a DATETIME value if the format string contains both date and time parts, or a DATE or TIME value if the string contains only date or time parts.

The date, time, or datetime values contained in str should be given in the format indicated by format. For the specifiers that can be used in format, see the DATE_FORMAT() function description. If str contains an illegal date, time, or datetime value, STR_TO_DATE() returns NULL. An illegal value also produces a warning."

I would like to change the above behaviour to throw an error when a string is tranformed using the format string argument and the resulting DATE, TIME, or DATETIME is not valid.

Any problems with this?

Also, what should the following return?

SELECT STR_TO_DATE(NULL, '%Y-%m-%d');

SELECT STR_TO_DATE(NULL, NULL);

MySQL returns a NULL value with no warning for both examples:

mysql> SELECT STR_TO_DATE(NULL, '%Y-%m-%d');
+-------------------------------+
| STR_TO_DATE(NULL, '%Y-%m-%d') |
+-------------------------------+
| NULL                          |
+-------------------------------+
1 row in set (0.00 sec)

mysql> SELECT STR_TO_DATE(NULL, NULL);
+-------------------------+
| STR_TO_DATE(NULL, NULL) |
+-------------------------+
| NULL                    |
+-------------------------+
1 row in set (0.00 sec)

Opinions please :)

Cheers,

Jay

_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help   : https://help.launchpad.net/ListHelp

Reply via email to