<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/153529</link>
    <title>MATLAB Central Newsreader - converting times</title>
    <description>Feed for thread: converting times</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>Fri, 27 Jul 2007 15:24:28 -0400</pubDate>
      <title>converting times</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/153529#385249</link>
      <author>Steve </author>
      <description>I have an excel file with a column of times in the format H:MM PM (i.e. 1:36 PM, 12:01 AM, etc.).  I would like to be able to import this column into matlab and convert the times to a 24-hr decimal equivalent.  For example, &lt;br&gt;
&lt;br&gt;
1:36 PM = 13.6000&lt;br&gt;
12:00 AM = 24.0000&lt;br&gt;
12:01 AM = 00.0167&lt;br&gt;
&lt;br&gt;
I think I can do it with a combination of 'datenum' and 'datestr', but I can't quite figure it out.  Any suggestions?  Thanks.</description>
    </item>
    <item>
      <pubDate>Fri, 27 Jul 2007 15:39:06 -0400</pubDate>
      <title>Re: converting times</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/153529#385251</link>
      <author>Andriy Nych</author>
      <description>&quot;Steve &quot; &amp;lt;steveDEL.bachmeierDEL@yahoo.com&amp;gt; wrote in message &amp;lt;f8d2nc$a3a$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I have an excel file with a column of times in the format H:MM PM (i.e. 1:36 PM, 12:01 AM, etc.).  I would like to be able to import this column into matlab and convert the times to a 24-hr decimal equivalent.  For example, &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 1:36 PM = 13.6000&lt;br&gt;
&amp;gt; 12:00 AM = 24.0000&lt;br&gt;
&amp;gt; 12:01 AM = 00.0167&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I think I can do it with a combination of 'datenum' and 'datestr', but I can't quite figure it out.  Any suggestions?  Thanks.&lt;br&gt;
&lt;br&gt;
Hope this will do the job&lt;br&gt;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;br&gt;
&amp;gt;&amp;gt; mod( datenum('1:36 PM'), 1 )*24&lt;br&gt;
ans =&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;13.6000&lt;br&gt;
&amp;gt;&amp;gt; mod( datenum('12:00 AM'), 1 )*24&lt;br&gt;
ans =&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0&lt;br&gt;
&amp;gt;&amp;gt; mod( datenum('12:01 AM'), 1 )*24&lt;br&gt;
ans =&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0.0167&lt;br&gt;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</description>
    </item>
    <item>
      <pubDate>Fri, 27 Jul 2007 15:58:43 -0400</pubDate>
      <title>Re: converting times</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/153529#385257</link>
      <author>Daniel Walker </author>
      <description>&lt;br&gt;
or... if you once end-up with a matlab datenum-format, you can also use datevec to get the hours/min/sec&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt; num = datenum('19-May-2000 11:36:00');&lt;br&gt;
&amp;gt;&amp;gt; vec = datevec(num);&lt;br&gt;
&amp;gt;&amp;gt; dec_time = vec(:,4)+vec(:,5)/60+vec(:,6)/3600&lt;br&gt;
&lt;br&gt;
dec_time =&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;11.6000&lt;br&gt;
&lt;br&gt;
D.</description>
    </item>
    <item>
      <pubDate>Fri, 27 Jul 2007 22:46:54 -0400</pubDate>
      <title>Re: converting times</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/153529#385327</link>
      <author>Steve </author>
      <description>Both suggestions work very well.  Thank you both.&lt;br&gt;
&lt;br&gt;
&quot;Daniel Walker &quot; &amp;lt;dwamail.nospam@gmx.ch&amp;gt; wrote in message &amp;lt;f8d4nj$nn$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; or... if you once end-up with a matlab datenum-format, you can also use datevec to get the hours/min/sec&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; num = datenum('19-May-2000 11:36:00');&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; vec = datevec(num);&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; dec_time = vec(:,4)+vec(:,5)/60+vec(:,6)/3600&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; dec_time =&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;    11.6000&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; D.</description>
    </item>
  </channel>
</rss>

