I have an SQL table, "data", with the following columns: id (int), date1 (datetime), date2 (datetime), difference (float)
What I would like to do is update this table so that the "difference" column contains the difference in years (as a float) between date2 and date1, only when date2 doesn't equal '0000-00-00 00:00:00'
I was thinking of something along the lines
Update data m
SET difference = datediff("hh",m.date2, m0.date1)/8765 --there are 8765 hours per year so this should give me my float
FROM data m0
WHERE m.id = m0.id
AND m.date2 <> '0000-00-00 00:00:00';
Yet when I try this I get an error stating "SQL syntax error. Check your MySQL server version for the right syntax to use near data SET difference = datediff("hh,m.date2,m0.date10/8765) from 'd' at line 1"
How would I modify my sql statement to get the desired results?
EDIT:
I am using xampp's phpMyAdmin interface to run this sql statement