select date(from_unixtime(int)) incorrectly returns 0000-00-00
Bug #814622 reported by
Robert Adams
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
InfiniDB Community |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
0000-00-00s are incorrect below:
create table test.ts (ts int(10)
insert into test.ts values(1302204355);
insert into test.ts values(1271117500);
insert into test.ts values(1302033274);
mysql> select ts, from_unixtime(ts), date(from_
+------
| ts | from_unixtime(ts) | d |
+------
| 1302204355 | 2011-04-07 14:25:55 | 0000-00-00 |
| 1271117500 | 2010-04-12 19:11:40 | 0000-00-00 |
| 1302033274 | 2011-04-05 14:54:34 | 0000-00-00 |
+------
3 rows in set, 3 warnings (0.03 sec)
Changed in infinidb: | |
status: | New → In Progress |
To post a comment you must log in.
Work around
mysql> alter table ts add column dtm datetime;
Query OK, 0 rows affected (0.67 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> update ts set dtm=from_ unixtime( ts);
Query OK, 3 rows affected (0.32 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql> select * from ts; ------+ ------- ------- ------- + ------+ ------- ------- ------- + ------+ ------- ------- ------- +
+------
| ts | dtm |
+------
| 1302204355 | 2011-04-07 14:25:55 |
| 1271117500 | 2010-04-12 19:11:40 |
| 1302033274 | 2011-04-05 14:54:34 |
+------
3 rows in set (0.10 sec)
mysql> select ts, from_unixtime(ts), date(from_ unixtime( ts)) d, ------+ ------- ------- ------- +------ ------+ ------- -----+ ------+ ------- ------- ------- +------ ------+ ------- -----+ ------+ ------- ------- ------- +------ ------+ ------- -----+
mysql> date(dtm) dt
from ts;
+------
| ts | from_unixtime(ts) | d | dt |
+------
| 1302204355 | 2011-04-07 14:25:55 | 0000-00-00 | 2011-04-07 |
| 1271117500 | 2010-04-12 19:11:40 | 0000-00-00 | 2010-04-12 |
| 1302033274 | 2011-04-05 14:54:34 | 0000-00-00 | 2011-04-05 |
+------
3 rows in set, 3 warnings (0.03 sec)