Anarquique... no sabria que decirte.
Mira lo que yo he hecho y nunca me da error.
Código mysql:
Ver originalQuery OK, 0 rows affected (0.16 sec)
Query OK, 1 row affected (0.05 sec)
Query OK, 1 row affected (0.00 sec)
+------------+--------------+-------------+
| fecha_fin | fecha_inicio | numero_dias |
+------------+--------------+-------------+
| 2009-06-09 | 2009-01-01 | NULL | | 2009-12-31 | 2009-06-09 | NULL | +------------+--------------+-------------+
Query OK, 2 rows affected (0.02 sec)
+------------+--------------+-------------+
| fecha_fin | fecha_inicio | numero_dias |
+------------+--------------+-------------+
| 2009-06-09 | 2009-01-01 | 159 |
| 2009-12-31 | 2009-06-09 | 205 |
+------------+--------------+-------------+
ERROR
1064 (42000): You have an error
in your SQL syntax
; check the manual that corresponds
to your MySQ
Query OK, 2 rows affected (0.16 sec)
Query OK, 2 rows affected (0.02 sec)
Query OK, 0 rows affected (0.00 sec)
mysql
> insert into anarquique
(fecha_fin
,fecha_inicio
) values('0000-00-00 00:00:00','0000-00-00 00:00:00Query OK, 1 row affected (0.00 sec)
mysql> update anarquique set numero_dias=datediff(fecha_fin,fecha_inicio);
Query OK, 0 rows affected (0.00 sec)
Rows matched: 3 Changed: 0 Warnings: 0
mysql> select *from anarquique;
+---------------------+---------------------+-------------+
| fecha_fin | fecha_inicio | numero_dias |
+---------------------+---------------------+-------------+
| 2009-06-09 00:00:00 | 2009-01-01 00:00:00 | 159 |
| 2009-12-31 00:00:00 | 2009-06-09 00:00:00 | 205 |
| 0000-00-00 00:00:00 | 0000-00-00 00:00:00 | NULL |
+---------------------+---------------------+-------------+
3 rows in set (0.00 sec)
mysql> insert into anarquique (fecha_fin,fecha_inicio) values('0000-00-00 00:00:00',now());
Query OK, 1 row affected (0.00 sec)
mysql> update anarquique set numero_dias=datediff(fecha_fin,fecha_inicio);
Query OK, 0 rows affected (0.00 sec)
Rows matched: 4 Changed: 0 Warnings: 0
mysql> select *from anarquique;
+---------------------+---------------------+-------------+
| fecha_fin | fecha_inicio | numero_dias |
+---------------------+---------------------+-------------+
| 2009-06-09 00:00:00 | 2009-01-01 00:00:00 | 159 |
| 2009-12-31 00:00:00 | 2009-06-09 00:00:00 | 205 |
| 0000-00-00 00:00:00 | 0000-00-00 00:00:00 | NULL |
| 0000-00-00 00:00:00 | 2009-06-09 07:50:11 | NULL |
+---------------------+---------------------+-------------+
4 rows in set (0.00 sec)
mysql> update anarquique set numero_dias=datediff(fecha_fin,fecha_inicio);
Query OK, 0 rows affected (0.00 sec)
Rows matched: 4 Changed: 0 Warnings: 0
mysql>
Asegurate que tanto fecha_fin como fecha_inicio sean tipo datetime, timestamp o date. Que numero_dias sea numerico (float, decimal) y no deberías tener problemas. Que versión de mysql usas?