octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #60671] Wrong result when subtracting one mont


From: Georg Wiora
Subject: [Octave-bug-tracker] [bug #60671] Wrong result when subtracting one month from 31-MON-YEAR date
Date: Tue, 25 May 2021 11:29:10 -0400 (EDT)
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:88.0) Gecko/20100101 Firefox/88.0

URL:
  <https://savannah.gnu.org/bugs/?60671>

                 Summary: Wrong result when subtracting one month from
31-MON-YEAR date
                 Project: GNU Octave
            Submitted by: gwiora
            Submitted on: Tue 25 May 2021 05:29:08 PM CEST
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: gwiora
        Originator Email: 
             Open/Closed: Open
                 Release: 5.2.0
         Discussion Lock: Any
        Operating System: Any

    _______________________________________________________

Details:

Subtracting one month from an end of month date in a month with 31 days
returns first of the same month as result instead of last day of earlier
month.

*Examples:*


>> datestr(addtodate(datenum('31-DEC-2020'),-1,'month'))
ans = 01-Dec-2020
>> datestr(addtodate(datenum('30-NOV-2020'),-1,'month'))
ans = 30-Oct-2020
>> datestr(addtodate(datenum('31-OCT-2020'),-1,'month'))
ans = 01-Oct-2020


The first and last result is expected to be 30-Nov-2020 and 30-Sep-2020.

I tested this on Mac OSX 10.15.7 with octave 5.2.0. The addtodate script was
located at:


/Applications/Octave-5.2.0.app/Contents/Resources/usr/Cellar/octave-octave-app@5.2.0/5.2.0/share/octave/5.2.0/m/time/addtodate.m





    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?60671>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]