I have 2 dates to compare so I can count years between both date. If days is less than 365 days then I use interval
to make it as 1 year. However I have problem if both date is similar in day for example 2019-10-15
to 2020-10-15
will be displayed as 2 years when I want it to be displayed as 1 year. Here is my code with not the result I want:
SELECT
TIMESTAMPDIFF(
YEAR,
'2019-10-15',
'2020-10-15' + INTERVAL 1 YEAR
) AS `year`
FROM
dob
Result:
What I want is:
2019-10-15
to 2020-10-14
= 1 year
2019-10-15
to 2020-10-15
= 1 year
2019-10-15
to 2020-10-16
= 2 year
How can I achieved that? Thanks in advance.