Re: Date Difference - Qsn
I have two dates and I want to find the difference in years between
them. I noticed the Date class doesn't provide me with such a function
like datediff. Will appreciate any pointers how I can go about this.
The "difference in years" could mean a number of
different things, for example:
- If T1 is 31-Dec-2007 23:59:59 and T2 is 01-Jan-2008
00:00:01, are T1 and T2 a year apart (they occur in
different calendar years), or about 0.0000000634 years
apart (two seconds)?
- Same situation, but assuming that the chronology wizards
add a leap second 23:59:60 to the end of December 2007.
- Same situation, but assuming that T1 is given in EDT
(UTC-5) and T2 in UTC.
- If T1 is 01-Jan-2008 00:00:00 UTC and T2 is 01-Jan-2009
00:00:00 UTC, are they one year apart, or a year and a
day apart, or a year and 18 hours (approximately) apart?
- If T1 is the birthday of Iannis Xenakis (29-May-1922) and
T2 is the date of his death (04-Feb-2001), how many years
apart are T1 and T2? Keep in mind that Xenakis was a Greek
composer, so the dates are given according to the calendars
used in Greece at the relevant times. Greece switched from
the Julian to the Gregorian calendar in 1923, so in that year
15-Feb was followed by 01-Mar; 1923 was only 352 days long in
Greece, about 3.56% shorter than most other years. Does that
affect your answer?
In short, before you can get a useful answer you need to
clarify your question. Exactly what do you mean by "the difference
in years" between two moments?