Hello,
What is the easiest way to add a year to a date?
If I do Date()+365, I will have an error with bisexual years.
I use...
LOCAL nDaysInYear := 365.25
dNewYear := dOldYear + nDaysInYear
To calculate someone's age
nAge := INT( ( dDob - dTargetDate ) / nDaysInYear )
On Monday, November 7, 2022 at 12:05:40 PM UTC-7, Robert wrote:
I use...
LOCAL nDaysInYear := 365.25
dNewYear := dOldYear + nDaysInYear
To calculate someone's age
nAge := INT( ( dDob - dTargetDate ) / nDaysInYear )
Fails when the dates surround 1900, or 2100, but good enough over YOUR lifetime. And it is the reverse of what is being asked for. Likely also fail near February 28 - March 1 more often than you'd like.
David A. Smith
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 77:52:35 |
Calls: | 6,658 |
Calls today: | 4 |
Files: | 12,203 |
Messages: | 5,332,968 |
Posted today: | 1 |