Other related problems:
Trailing spaces change the result of TIME():
SELECT TIME('2001-01-01') AS c1, TIME('2001-01-01 ') AS c2;
|
+----------+----------+
|
| c1 | c2 |
|
+----------+----------+
|
| 00:20:01 | 00:00:00 |
|
+----------+----------+
|
SELECT TIME('0001:01:01 '), TIME('0001:01:01 ');
|
+---------------------+----------------------+
|
| TIME('0001:01:01 ') | TIME('0001:01:01 ') |
|
+---------------------+----------------------+
|
| 01:01:01 | 00:00:00 |
|
+---------------------+----------------------+
|
SELECT TIME('1 2'), TIME('1 2 ');
|
+-------------+--------------+
|
| TIME('1 2') | TIME('1 2 ') |
|
+-------------+--------------+
|
| 00:00:01 | 26:00:00 |
|
+-------------+--------------+
|
Trailing spaces following DATE + 'T' (date/time separator) change the meaning of TIME():
SELECT TIME('2001-01-01T'), TIME('2001-01-01T ');
|
+---------------------+----------------------+
|
| TIME('2001-01-01T') | TIME('2001-01-01T ') |
|
+---------------------+----------------------+
|
| 00:20:01 | 00:00:00 |
|
+---------------------+----------------------+
|
SELECT TIME('00901-01-01'), TIME('00901-01-01T');
|
+---------------------+----------------------+
|
| TIME('00901-01-01') | TIME('00901-01-01T') |
|
+---------------------+----------------------+
|
| 00:09:01 | 00:00:00 |
|
+---------------------+----------------------+
|
Different result for 'T' with trailing digits in TIME()
SELECT TIME('901-01-01T1'), TIME('901-01-01T10');
|
+---------------------+----------------------+
|
| TIME('901-01-01T1') | TIME('901-01-01T10') |
|
+---------------------+----------------------+
|
| 00:09:01 | 10:00:00 |
|
+---------------------+----------------------+
|
SELECT TIME('091-01-01T1'), TIME('091-01-01T10');
|
+---------------------+----------------------+
|
| TIME('091-01-01T1') | TIME('091-01-01T10') |
|
+---------------------+----------------------+
|
| NULL | 10:00:00 |
|
+---------------------+----------------------+
|
Trailing garbage change the result of TIME()
SELECT TIME('0001:01:01x'), TIME('0001:01:01xx');
|
+---------------------+----------------------+
|
| TIME('0001:01:01x') | TIME('0001:01:01xx') |
|
+---------------------+----------------------+
|
| 01:01:01 | 00:00:00 |
|
+---------------------+----------------------+
|
but not if the garbage is punctuation:
SELECT TIME('0001:01:01.'), TIME('0001:01:01..');
|
+---------------------+----------------------+
|
| TIME('0001:01:01.') | TIME('0001:01:01..') |
|
+---------------------+----------------------+
|
| 01:01:01 | 01:01:01 |
|
+---------------------+----------------------+
|
SELECT TIME('0001:01:01-'), TIME('0001:01:01--');
|
+---------------------+----------------------+
|
| TIME('0001:01:01-') | TIME('0001:01:01--') |
|
+---------------------+----------------------+
|
| 01:01:01 | 01:01:01 |
|
+---------------------+----------------------+
|
SELECT TIME('0001:01:01-'), TIME('0001:01:01--');
|
+---------------------+----------------------+
|
| TIME('0001:01:01-') | TIME('0001:01:01--') |
|
+---------------------+----------------------+
|
| 01:01:01 | 01:01:01 |
|
+---------------------+----------------------+
|
TIME() produces negative zero for the minus followed by garbage
SELECT TIME('-xxx'), TIME('-xxxxxxxxxxxxxxxxxxxx');
|
+--------------+-------------------------------+
|
| TIME('-xxx') | TIME('-xxxxxxxxxxxxxxxxxxxx') |
|
+--------------+-------------------------------+
|
| -00:00:00 | -00:00:00 |
|
+--------------+-------------------------------+
|
SELECT TIME('- '), TIME('- ');
|
+-----------------+------------------------------------+
|
| TIME('- ') | TIME('- ') |
|
+-----------------+------------------------------------+
|
| -00:00:00 | -00:00:00 |
|
+-----------------+------------------------------------+
|
But TIME() with a sign only produces NULL
SELECT TIME('-'), TIME('-');
|
+-----------+-----------+
|
| TIME('-') | TIME('-') |
|
+-----------+-----------+
|
| NULL | NULL |
|
+-----------+-----------+
|
This is different comparing to sign followed by garbage and time followed by spaces (see above).
Examples when zero fractional digits change the meaning completely
SELECT TIME('1-1-1 1:1:1'), TIME('1-1-1 1:1:1.0');
|
+---------------------+-----------------------+
|
| TIME('1-1-1 1:1:1') | TIME('1-1-1 1:1:1.0') |
|
+---------------------+-----------------------+
|
| 00:00:01 | 01:01:01.0 |
|
+---------------------+-----------------------+
|
Other related problems:
Trailing spaces change the result of TIME():
+----------+----------+
| c1 | c2 |
+----------+----------+
| 00:20:01 | 00:00:00 |
+----------+----------+
+---------------------+----------------------+
| TIME('0001:01:01 ') | TIME('0001:01:01 ') |
+---------------------+----------------------+
| 01:01:01 | 00:00:00 |
+---------------------+----------------------+
+-------------+--------------+
| TIME('1 2') | TIME('1 2 ') |
+-------------+--------------+
| 00:00:01 | 26:00:00 |
+-------------+--------------+
Trailing spaces following DATE + 'T' (date/time separator) change the meaning of TIME():
+---------------------+----------------------+
| TIME('2001-01-01T') | TIME('2001-01-01T ') |
+---------------------+----------------------+
| 00:20:01 | 00:00:00 |
+---------------------+----------------------+
+---------------------+----------------------+
| TIME('00901-01-01') | TIME('00901-01-01T') |
+---------------------+----------------------+
| 00:09:01 | 00:00:00 |
+---------------------+----------------------+
Different result for 'T' with trailing digits in TIME()
+---------------------+----------------------+
| TIME('901-01-01T1') | TIME('901-01-01T10') |
+---------------------+----------------------+
| 00:09:01 | 10:00:00 |
+---------------------+----------------------+
+---------------------+----------------------+
| TIME('091-01-01T1') | TIME('091-01-01T10') |
+---------------------+----------------------+
| NULL | 10:00:00 |
+---------------------+----------------------+
Trailing garbage change the result of TIME()
+---------------------+----------------------+
| TIME('0001:01:01x') | TIME('0001:01:01xx') |
+---------------------+----------------------+
| 01:01:01 | 00:00:00 |
+---------------------+----------------------+
but not if the garbage is punctuation:
+---------------------+----------------------+
| TIME('0001:01:01.') | TIME('0001:01:01..') |
+---------------------+----------------------+
| 01:01:01 | 01:01:01 |
+---------------------+----------------------+
+---------------------+----------------------+
| TIME('0001:01:01-') | TIME('0001:01:01--') |
+---------------------+----------------------+
| 01:01:01 | 01:01:01 |
+---------------------+----------------------+
+---------------------+----------------------+
| TIME('0001:01:01-') | TIME('0001:01:01--') |
+---------------------+----------------------+
| 01:01:01 | 01:01:01 |
+---------------------+----------------------+
TIME() produces negative zero for the minus followed by garbage
+--------------+-------------------------------+
| TIME('-xxx') | TIME('-xxxxxxxxxxxxxxxxxxxx') |
+--------------+-------------------------------+
| -00:00:00 | -00:00:00 |
+--------------+-------------------------------+
+-----------------+------------------------------------+
| TIME('- ') | TIME('- ') |
+-----------------+------------------------------------+
| -00:00:00 | -00:00:00 |
+-----------------+------------------------------------+
But TIME() with a sign only produces NULL
+-----------+-----------+
| TIME('-') | TIME('-') |
+-----------+-----------+
| NULL | NULL |
+-----------+-----------+
This is different comparing to sign followed by garbage and time followed by spaces (see above).
Examples when zero fractional digits change the meaning completely
+---------------------+-----------------------+
| TIME('1-1-1 1:1:1') | TIME('1-1-1 1:1:1.0') |
+---------------------+-----------------------+
| 00:00:01 | 01:01:01.0 |
+---------------------+-----------------------+