octave datevec() v/s Excel/LibreOffice

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

octave datevec() v/s Excel/LibreOffice

jmb-2
Hello,

I am finding a difference between how octave interprets a serial date to
a date string versus what LibreOffice/MS-Excel show:

A. LibreOffice / MS-Excel:
        '41908.402198066' -> 09/26/2014 09:39:10  (which is correct)
B. Octave:
        datevec(41908.402198066)
        ans =
    114.0000     9.0000    27.0000     9.0000    39.0000     9.9129

(Tested in Octave 3.2.4 & 3.8.1 running in 64bit Ubuntu 12.04+)

I assume that 114 means 2014, but why do I get 27th instead of the
correct 26Sep2014?  What am I doing wrong or missing?  Any help would be
appreciated.  Thank you.

Regards, JMB

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: octave datevec() v/s Excel/LibreOffice

Mike Miller
On Mon, Sep 29, 2014 at 10:45:41 -0400, jmb wrote:

> Hello,
>
> I am finding a difference between how octave interprets a serial date to
> a date string versus what LibreOffice/MS-Excel show:
>
> A. LibreOffice / MS-Excel:
>         '41908.402198066' -> 09/26/2014 09:39:10  (which is correct)
> B. Octave:
>         datevec(41908.402198066)
>         ans =
>         114.0000     9.0000    27.0000     9.0000    39.0000     9.9129
>
> (Tested in Octave 3.2.4 & 3.8.1 running in 64bit Ubuntu 12.04+)
>
> I assume that 114 means 2014, but why do I get 27th instead of the
> correct 26Sep2014?  What am I doing wrong or missing?  Any help would be
> appreciated.  Thank you.

Hi JMB, you'll probably find the m2xdate function helpful:

  http://octave.sourceforge.net/financial/function/m2xdate.html

HTH,

--
mike

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: octave datevec() v/s Excel/LibreOffice

jmb-2
On 09/29/2014 11:07 AM, Mike Miller wrote:

> On Mon, Sep 29, 2014 at 10:45:41 -0400, jmb wrote:
>> Hello,
>> I am finding a difference between how octave interprets a serial date to
>> a date string versus what LibreOffice/MS-Excel show:
>>
>> A. LibreOffice / MS-Excel:
>>         '41908.402198066' -> 09/26/2014 09:39:10  (which is correct)
>> B. Octave:
>>         datevec(41908.402198066)
>>         ans =
>>         114.0000     9.0000    27.0000     9.0000    39.0000     9.9129
>> (Tested in Octave 3.2.4 & 3.8.1 running in 64bit Ubuntu 12.04+)
>> I assume that 114 means 2014, but why do I get 27th instead of the
>> correct 26Sep2014?  What am I doing wrong or missing?  Any help would be
>> appreciated.  Thank you.
> Hi JMB, you'll probably find the m2xdate function helpful:
>   http://octave.sourceforge.net/financial/function/m2xdate.html
> HTH,
>
Hello Mike,

Thanks for your suggestion.  I installed io & financial
    pkg install -forge -verbose io financial
    pkg load io financial
    serial = 41908.402198066;
    m2xdate(serial);
    warning: Negative date found, this will not work within MS excel
    ans = -6.2505e+05

I tried variants of m2xdate(serial, [1/0], [""/"ExcelBug"]); all
resulting in the same error/warning.
I am puzzled ... !  Any other suggestions?  Thank you.

Regards, JMB



_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: octave datevec() v/s Excel/LibreOffice

Mike Miller
On Mon, Sep 29, 2014 at 11:47:11 -0400, jmb wrote:

> Thanks for your suggestion.  I installed io & financial
>     pkg install -forge -verbose io financial
>     pkg load io financial
>     serial = 41908.402198066;
>     m2xdate(serial);
>     warning: Negative date found, this will not work within MS excel
>     ans = -6.2505e+05
>
> I tried variants of m2xdate(serial, [1/0], [""/"ExcelBug"]); all
> resulting in the same error/warning.
> I am puzzled ... !  Any other suggestions?  Thank you.

I wasn't sure in which direction you want to convert. Did you see the
reference to x2mdate in the help? They seem like inverses of each
other to me.

m2xdate == Matlab-to-Excel basis conversion
x2mdate == Excel-to-Matlab basis conversion

So feed your Excel/LibreOffice number into x2mdate to get a valid
Octave datenum. Use m2xdate to convert an Octave datenum into
something a spreadsheet can use.

HTH,

--
mike

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave