I did once sit down and write an algorithm (not a formula) that would, for example, give me the day of the week when Christ was supposedly born. (He was born on a Thursday, the same day of the week as me!) If I can write such an algorithm I can't see why you couldn't write one to find the number of days between two dates.
I would start with the years: Find the difference in the number of years and you've got 365 days for each year. Then break it down into how many months and which months they are. etc.