A.D. Tejpal
adtp at airtelmail.in
Sun Mar 28 23:41:31 CDT 2010
Feasibility of a universal function for calculation of date difference in terms of completed years, months and days has often featured in various discussion groups. It is also referred as age calculation function when second argument is optional and defaults to today's date. Over the years, different flavors of such a function have been attempted. In this regard, it would be desirable to evolve a consensus as to the governing rules to be followed for computing the results. Proposed draft guidelines are placed below (Let Dy1 & Dy2 be the day parts of start & end dates respectively. Let Dy represent days count in final result): ========================================== 1 - If both Dy1 & Dy2 represent ends of respective months, day part of the final result (Dy) is zero. 2 - If Dy2 is at the end of month and Dy1 is not, Dy equals unfinished days in start month. 3 - If Dy1 is at the end of month and Dy2 is not, Dy equals Dy2. 4 - If neither date represents end of the month, and Dy2 >= Dy1, result days (Dy) = Dy2 - Dy1. 5 - If neither date represents end of the month, and Dy2 < Dy1, result days (Dy) is computed by adding Dy2 and unfinished days in start month. ========================================== It would be nice, if interested members could kindly examine the above and offer their considered views regarding modifications to the draft guidelines, as felt necessary. Best wishes, A.D. Tejpal ------------