Converting pair of dates into year and fraction of year?

Is there an online function to convert a start date and an end date into the total time?

I’ve got a long list of dates that I want to do some cipherin’ with, and need the total time for each pair of dates. EG - jan1 1982 to june30 1983 is 1.5 years

I could do it manually, but would prefer to just plug them in to a pair of fields and let the interwebs do the calculation for me.

If you have the data in Excel you could use the DATEDIF function, and make columns for “days between”, “weeks between,” “months between” and “years between” for each set and then see which figure is the most meaningful for each pairing.

Google “excel datedif” for tons of help.

In spreadsheets you can generally just subtract one date from another, because under the hood they are just numbers. So (enddate - startdate)/365.25 will give a pretty close approximation of the number of years, in the decimal format mentioned by the OP. It works in Google Spreadsheet, so that’s “online”.
It’s not accurate enough if you need more decimal places.

Interestingly, different year fraction conventions are the bread and butter of a lot of finance work. There are dozens of options to choose from. When money is involved, people tend to get very precise.

Ximenean’s method will get you a pretty good approximation. To get more accurate, you’ll need to specify how you want to handle leap years. Should your “number of years” function return the same result for Jan 1, 2000 to July 1, 2001 as it does for Jan 1, 2001 to July 1, 2002, even though there were different numbers of days between those two pairs of dates? Should January 1–31, 2000 count as a different “fraction” of a year as January 1–31, 2001 (31/366 vs. 31/365)?

In my opinion, the most justifiable methods are either to count every day as 1/365.25 of a year (which will answer “no” to the first question above and “yes” to the second), or to say that each day in a common year is 1/365 of a year and each day in a leap year is 1/366 (“no” to the first, “no” to the second.) Getting a universal method that answers the first question above in the affirmative would be kind of kludgey, in my opinion.

The Wolfram site and app can do it too.

Thanks for all the suggestions, everyone - very helpful. I’ll noodle around a bit to see which of these options works best for me.

I’d say Wolfram Alpha which has already been suggested is the easiest solution. You just type your query like this:

time span 1980-01-10 to 1986-09-21

and get your result: