• Date + one year

    From Otto Haldi@21:1/5 to All on Mon Oct 31 07:29:11 2022
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robert Campsmith@21:1/5 to Otto Haldi on Mon Nov 7 14:05:37 2022
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dlzc@21:1/5 to Robert on Tue Nov 8 07:14:25 2022
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robert Campsmith@21:1/5 to dlzc on Tue Nov 15 14:29:26 2022
    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

    On 11/8/2022 10:14 AM, dlzc wrote:
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)