<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/151477</link>
    <title>MATLAB Central Newsreader - datestr problems</title>
    <description>Feed for thread: datestr problems</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Tue, 03 Jul 2007 14:34:09 -0400</pubDate>
      <title>datestr problems</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/151477#380895</link>
      <author>Kelly</author>
      <description>I'm seeing some odd behavior with the datestr function. There seems&lt;br&gt;
to be an upper limit on the value of the month number in the input&lt;br&gt;
date vector in order to return the proper string. For example,&lt;br&gt;
&lt;br&gt;
datestr([1950 522 15 12 0 0])&lt;br&gt;
&lt;br&gt;
ans =&lt;br&gt;
&lt;br&gt;
15-Jun-1993 12:00:00&lt;br&gt;
&lt;br&gt;
This is the answer that I was expecting. However,&lt;br&gt;
&lt;br&gt;
datestr([1950 523 15 12 0 0])&lt;br&gt;
&lt;br&gt;
ans =&lt;br&gt;
&lt;br&gt;
03-May-0005&lt;br&gt;
06-Jun-0001&lt;br&gt;
15-Jan-0000&lt;br&gt;
12-Jan-0000&lt;br&gt;
00-Jan-0000&lt;br&gt;
00-Jan-0000&lt;br&gt;
&lt;br&gt;
The problem seems to occur somewhere in the mex file that does the&lt;br&gt;
major calculations (datevecmx); for some reason it is returning 6 x 1&lt;br&gt;
vectors for the year, month, etc, instead of the scalar values it&lt;br&gt;
should be getting.&lt;br&gt;
&lt;br&gt;
Does anyone else see this behavior? Also, does anyone know of a&lt;br&gt;
workaround? I have a lot of data that is given in &quot;months since&lt;br&gt;
1950&quot;, and I am looking for an easy way to convert this to&lt;br&gt;
dd-mmm-yyyy strings.&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
Kelly</description>
    </item>
    <item>
      <pubDate>Tue, 03 Jul 2007 14:55:00 -0400</pubDate>
      <title>Re: datestr problems</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/151477#380899</link>
      <author>Jos</author>
      <description>Kelly wrote:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I'm seeing some odd behavior with the datestr function. There&lt;br&gt;
&amp;gt; seems&lt;br&gt;
&amp;gt; to be an upper limit on the value of the month number in the input&lt;br&gt;
&amp;gt; date vector in order to return the proper string. For example,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; datestr([1950 522 15 12 0 0])&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; ans =&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; 15-Jun-1993 12:00:00&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; This is the answer that I was expecting. However,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; datestr([1950 523 15 12 0 0])&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; ans =&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; 03-May-0005&lt;br&gt;
&amp;gt; 06-Jun-0001&lt;br&gt;
&amp;gt; 15-Jan-0000&lt;br&gt;
&amp;gt; 12-Jan-0000&lt;br&gt;
&amp;gt; 00-Jan-0000&lt;br&gt;
&amp;gt; 00-Jan-0000&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; The problem seems to occur somewhere in the mex file that does the&lt;br&gt;
&amp;gt; major calculations (datevecmx); for some reason it is returning 6 x&lt;br&gt;
&amp;gt; 1&lt;br&gt;
&amp;gt; vectors for the year, month, etc, instead of the scalar values it&lt;br&gt;
&amp;gt; should be getting.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Does anyone else see this behavior? Also, does anyone know of a&lt;br&gt;
&amp;gt; workaround? I have a lot of data that is given in &quot;months since&lt;br&gt;
&amp;gt; 1950&quot;, and I am looking for an easy way to convert this to&lt;br&gt;
&amp;gt; dd-mmm-yyyy strings.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Thanks,&lt;br&gt;
&amp;gt; Kelly&lt;br&gt;
&amp;nbsp;&amp;nbsp;&lt;br&gt;
I see the same behavior. A workaround is to convert the date vector&lt;br&gt;
to a datenumber&lt;br&gt;
&lt;br&gt;
datestr([1950 523 15 12 0 0])&lt;br&gt;
% --&amp;gt; list of dates&lt;br&gt;
&lt;br&gt;
datestr(datenum([1950 523 15 12 0 0]))&lt;br&gt;
% --&amp;gt; 15-Jul-1993 12:00:00&lt;br&gt;
&lt;br&gt;
hth&lt;br&gt;
Jos</description>
    </item>
    <item>
      <pubDate>Tue, 03 Jul 2007 16:43:24 -0400</pubDate>
      <title>Re: datestr problems</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/151477#380919</link>
      <author>per isakson</author>
      <description>Jos wrote:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Kelly wrote:&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; I'm seeing some odd behavior with the datestr function. There&lt;br&gt;
&amp;gt;&amp;gt; seems&lt;br&gt;
&amp;gt;&amp;gt; to be an upper limit on the value of the month number in the&lt;br&gt;
&amp;gt; input&lt;br&gt;
&amp;gt;&amp;gt; date vector in order to return the proper string. For example,&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; datestr([1950 522 15 12 0 0])&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; ans =&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; 15-Jun-1993 12:00:00&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; This is the answer that I was expecting. However,&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; datestr([1950 523 15 12 0 0])&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; ans =&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; 03-May-0005&lt;br&gt;
&amp;gt;&amp;gt; 06-Jun-0001&lt;br&gt;
&amp;gt;&amp;gt; 15-Jan-0000&lt;br&gt;
&amp;gt;&amp;gt; 12-Jan-0000&lt;br&gt;
&amp;gt;&amp;gt; 00-Jan-0000&lt;br&gt;
&amp;gt;&amp;gt; 00-Jan-0000&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; The problem seems to occur somewhere in the mex file that does&lt;br&gt;
&amp;gt; the&lt;br&gt;
&amp;gt;&amp;gt; major calculations (datevecmx); for some reason it is returning&lt;br&gt;
6&lt;br&gt;
&amp;gt; x&lt;br&gt;
&amp;gt;&amp;gt; 1&lt;br&gt;
&amp;gt;&amp;gt; vectors for the year, month, etc, instead of the scalar values&lt;br&gt;
it&lt;br&gt;
&amp;gt;&amp;gt; should be getting.&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; Does anyone else see this behavior? Also, does anyone know of&lt;br&gt;
a&lt;br&gt;
&amp;gt;&amp;gt; workaround? I have a lot of data that is given in &quot;months&lt;br&gt;
since&lt;br&gt;
&amp;gt;&amp;gt; 1950&quot;, and I am looking for an easy way to convert this to&lt;br&gt;
&amp;gt;&amp;gt; dd-mmm-yyyy strings.&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; Thanks,&lt;br&gt;
&amp;gt;&amp;gt; Kelly&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I see the same behavior. A workaround is to convert the date vector&lt;br&gt;
&amp;gt; to a datenumber&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; datestr([1950 523 15 12 0 0])&lt;br&gt;
&amp;gt; % --&amp;gt; list of dates&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; datestr(datenum([1950 523 15 12 0 0]))&lt;br&gt;
&amp;gt; % --&amp;gt; 15-Jul-1993 12:00:00&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; hth&lt;br&gt;
&amp;gt; Jos&lt;br&gt;
&amp;nbsp;&amp;nbsp;&lt;br&gt;
The problem is with this boolean expression&lt;br&gt;
&lt;br&gt;
all(abs(sum(D,2)-2000)&amp;lt;500) in line 167 of R2006b&lt;br&gt;
&lt;br&gt;
The doc says:&lt;br&gt;
&lt;br&gt;
A 3- or 6-element vector having a first element within an&lt;br&gt;
approximate range of 500 greater than or less than the current year&lt;br&gt;
is considered by MATLAB to be a date vector. Otherwise, it is&lt;br&gt;
considered to be a vector of serial date numbers.&lt;br&gt;
&lt;br&gt;
Someone didn't think about month having large values - I guess. Code&lt;br&gt;
and documentation don't match exactly.&lt;br&gt;
&lt;br&gt;
/ per</description>
    </item>
  </channel>
</rss>

