Calculating the date difference in years
Posted on 2006-03-27
I think there must be a straightforward answer to this but its escaping me!
I want to work out the difference between 2 dates in years. I don't want to use datediff('yy'... because this does a year() calculation so 01/jan/2001 is a year on from 31/dec/2000. I want to do it on the basis that a year is 365 days. so
01/jan/2001 - 31/dec/2000 = 0 years
01/jan/2001 - 31/dec/2001 = 1 year
22/mar/2005 - 21/mar/2005 = 1 year
and so on so basically I want to do a datediff(dd, start, end) / 365 but I would like to take account of the leep year.