Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Date + one year

85 views
Skip to first unread message

Robert Campsmith

unread,
Nov 7, 2022, 2:05:40 PM11/7/22
to
I use...


LOCAL nDaysInYear := 365.25

dNewYear := dOldYear + nDaysInYear

To calculate someone's age

nAge := INT( ( dDob - dTargetDate ) / nDaysInYear )

Good Luck,
-- Robert


On 10/31/2022 10:29 AM, Otto Haldi wrote:
> 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.

dlzc

unread,
Nov 8, 2022, 10:14:26 AM11/8/22
to
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

Robert Campsmith

unread,
Nov 15, 2022, 2:29:36 PM11/15/22
to
Thanks David,

As I may have mentioned, I use this to calculate someone's age as of a
certain date. Not calculating the orbit to Mars. Just thought it might
be a useful shortcut. You are correct in that to calculate EXACTLY one
year you must go thorough all the what-if tests.

-- Robert
0 new messages