This is my first post (and English is not my mother tongue) so I hope I won't screw this post up.
I am new to MySQL but I learned a lot with 100+ youtube tutorials and your numerous posts. I designed my database using PHPmyadmin and MySQL Workbench.
In my table
subventions (grants), I created a trigger to be able to calculate the annual amount of money of a grant, using my columns
subventions.fin (end) and
DATEDIFF only gives me an answer in days, I naively thought that I only had to divide it by 365 days to obtain my answer. It works if my beginning date is the first of january and the end date the 31st of December, but does not if it stars somewhere else during the year. Here is my trigger:
SET NEW.montant_annuel = NEW.montant / (datediff(NEW.fin,NEW.début)/365)
If I use 365.25 (which is the "real" number of days in a year), it does not work either.