Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Function to determine age, with part years?
Message
From
01/12/2010 16:29:25
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Function to determine age, with part years?
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01491452
Message ID:
01491452
Views:
115
Hi all,

Does anyone have a bulletproof function to determine "age" between 2 dates - that takes into account leap years and also is able to report back part years (as a decimal part of the number) e.g. 21.3671 for 21 years and 134 days into the next year.

I wrote one years ago that loops through the years between the start date and end date adjusting for leap years and it works for the most part. It slows the report down somewhat as it is called a few hundred times and has to run this loop each time.

The customer wants it to be "accurate" for the decimal part so that if it was 134 days into the new years and that year is not a leap year, it would return .3671 for the decimal portion (134/365) and if it *was* a leap year, it would return .3661 (134/365). Not sure their "logic" on that last bit is "correct" but that's what they want.

So in short, a faster function than a loop would be good as long as it can return days as a decimal fraction.

thanks,
Albert Gostick
Next
Reply
Map
View

Click here to load this message in the networking platform