<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How dhms is calculating hours, minutes and seconds? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-dhms-is-calculating-hours-minutes-and-seconds/m-p/875001#M345730</link>
    <description>&lt;P&gt;Correct, though actually running the code should have been to confirm what you expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The behavior of the DHMS and the related MDY functions is a bit more flexible than sometimes expected. I had what I thought was an odd value when doing some conversion from some old files with a date value that was out of order. The records were very intermittent dates and could go a fair amount of time between measures but the records were supposed to be sequential. After reading the source file using the MDY function to build the dates one was out of order. The Day value was 67. So a November date, that likely should have been either 6 or 7 became one in January of the next year.&lt;/P&gt;
&lt;P&gt;Part of the fun with ETL processes. Trying to track down the correct date on a file that originated as manual data entry 20 years earlier was entertaining.&lt;/P&gt;</description>
    <pubDate>Wed, 10 May 2023 15:39:47 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-05-10T15:39:47Z</dc:date>
    <item>
      <title>How dhms is calculating hours, minutes and seconds?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-dhms-is-calculating-hours-minutes-and-seconds/m-p/874947#M345708</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;In the&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://documentation.sas.com/," target="_blank" rel="noopener"&gt;https://documentation.sas.com/,&lt;/A&gt;&amp;nbsp;I see the following code:&lt;/P&gt;&lt;P&gt;data one;&lt;BR /&gt;dtid=dhms('09feb21'd, 15, 30, 15);&lt;BR /&gt;put dtid;&lt;BR /&gt;put dtid datetime.;&lt;BR /&gt;&lt;BR /&gt;dtid2=dhms('09feb21'd, 15, 30, 61);&lt;BR /&gt;put dtid2;&lt;BR /&gt;put dtid2 datetime.;&lt;BR /&gt;&lt;BR /&gt;dtid3=dhms('09feb21'd, 15, .5, 15);&lt;BR /&gt;put dtid3;&lt;BR /&gt;put dtid3 datetime.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;SAS writes these results to the log:&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;1928503815
09FEB21:15:30:15
1928503861
09FEB21:15:31:01
1928502045
09FEB21:15:00:45&lt;/PRE&gt;&lt;P&gt;Can anyone please clarify why&amp;nbsp;dtid3 is showing 15:00:45 for the time part when we have given 15 for hours, .5 for minutes and 15 for seconds?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For&amp;nbsp;dtid2, I am thinking that it is calculating as follows:&lt;/P&gt;&lt;P&gt;we have given 15,30, 61 for hour, minute and second respectively. Since 61 seconds = 1 min + 1 second, hence in the output we have 30+ this 1 minute=31 minutes and for seconds, it is taking the remaining 1 second out of 61 seconds. Please, let me know if my understanding regarding dtid2 is correct or not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For dtid3, I am not able to apply such logic. Please, help me understand how dhms works with the time part and why dtid2 time part is 15:00:45.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 10 May 2023 13:51:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-dhms-is-calculating-hours-minutes-and-seconds/m-p/874947#M345708</guid>
      <dc:creator>Moksha</dc:creator>
      <dc:date>2023-05-10T13:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: How dhms is calculating hours, minutes and seconds?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-dhms-is-calculating-hours-minutes-and-seconds/m-p/874948#M345709</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/439180"&gt;@Moksha&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;DIV class=""&gt;
&lt;P&gt;Can anyone please clarify why&amp;nbsp;dtid3 is showing 15:00:45 for the time part when we have given 15 for hours, .5 for minutes and 15 for seconds?&lt;/P&gt;
&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Let's see here ... 15 hours, one half a minute and 15 seconds ... without using SAS, that's 15 hours, and then half a minute and then 15 seconds, how many seconds is that? How many minutes is half a minute and then another 15 seconds? Please figure that out in your head, without SAS. Show the steps/explain your answer.&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 14:00:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-dhms-is-calculating-hours-minutes-and-seconds/m-p/874948#M345709</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-10T14:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: How dhms is calculating hours, minutes and seconds?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-dhms-is-calculating-hours-minutes-and-seconds/m-p/874958#M345712</link>
      <description>&lt;P&gt;It is just doing arithmetic.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DateTime
&amp;nbsp; =&amp;nbsp;Number_of_days*(Seconds_per_day)
&amp;nbsp; + Number_of_Hours*(Seconds_per_hour)
&amp;nbsp; + Number_of_Minutes*(Seconds_per_minute)
&amp;nbsp; + Number_of_Seconds
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DateTime = D*'24:00:00't + H*'01:00:00't+M*'00:01:00't+S;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 May 2023 14:20:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-dhms-is-calculating-hours-minutes-and-seconds/m-p/874958#M345712</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-05-10T14:20:23Z</dc:date>
    </item>
    <item>
      <title>Re: How dhms is calculating hours, minutes and seconds?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-dhms-is-calculating-hours-minutes-and-seconds/m-p/874959#M345713</link>
      <description>&lt;P&gt;Thanks PaigeMiller. As mentioned by you, now I understand that .5 minutes is 30 seconds. So, out of 60 seconds (1 minute), we have mentioned 30 seconds only, hence minute part is 00 and this 30 seconds added to the seconds part and hence 30 + 15 seconds = 45 seconds. Is that correct?&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 14:23:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-dhms-is-calculating-hours-minutes-and-seconds/m-p/874959#M345713</guid>
      <dc:creator>Moksha</dc:creator>
      <dc:date>2023-05-10T14:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: How dhms is calculating hours, minutes and seconds?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-dhms-is-calculating-hours-minutes-and-seconds/m-p/874960#M345714</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/439180"&gt;@Moksha&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks PaigeMiller. As mentioned by you, now I understand that .5 minutes is 30 seconds. So, out of 60 seconds (1 minute), we have mentioned 30 seconds only, hence minute part is 00 and this 30 seconds added to the seconds part and hence 30 + 15 seconds = 45 seconds. Is that correct?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Correct! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt; &lt;span class="lia-unicode-emoji" title=":hundred_points:"&gt;💯&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 14:24:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-dhms-is-calculating-hours-minutes-and-seconds/m-p/874960#M345714</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-10T14:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: How dhms is calculating hours, minutes and seconds?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-dhms-is-calculating-hours-minutes-and-seconds/m-p/874962#M345715</link>
      <description>&lt;P&gt;Ok, thank you very much PaigeMiller. Your answer helped me a lot.&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 14:26:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-dhms-is-calculating-hours-minutes-and-seconds/m-p/874962#M345715</guid>
      <dc:creator>Moksha</dc:creator>
      <dc:date>2023-05-10T14:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: How dhms is calculating hours, minutes and seconds?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-dhms-is-calculating-hours-minutes-and-seconds/m-p/874966#M345718</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/439180"&gt;@Moksha&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Ok, thank you very much PaigeMiller. Your answer helped me a lot.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Now with that understanding what would you expect for&lt;/P&gt;
&lt;PRE&gt;dtid4=dhms('09feb21'd, 39, 30, 61);&lt;/PRE&gt;
&lt;P&gt;As in what happens when hours are increased for 15 to 39 (hint: +24)&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 14:32:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-dhms-is-calculating-hours-minutes-and-seconds/m-p/874966#M345718</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-10T14:32:29Z</dc:date>
    </item>
    <item>
      <title>Re: How dhms is calculating hours, minutes and seconds?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-dhms-is-calculating-hours-minutes-and-seconds/m-p/874984#M345724</link>
      <description>&lt;P&gt;Hi ballardw, thanks for bringing this out.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried the code you have given:&lt;/P&gt;&lt;P&gt;dtid4=dhms('09feb21'd, 39, 30, 61);&lt;BR /&gt;put dtid4;&lt;BR /&gt;put dtid4 datetime.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and output is :&lt;/P&gt;&lt;P&gt;1928590261&lt;BR /&gt;10FEB21:15:31:01&lt;/P&gt;&lt;P&gt;My understanding is that : 39 hours = 24 hours + 15 hours. Out of these, since 24 hours is 1 day, date changed to 10FEB2021 and hence remaining 15 hours are mentioned for hours.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, for minutes and seconds: since 61 seconds = 1 minute + 1 second, out of these 1 minute is added to 30 minutes and hence 31 minutes and the seconds part is 1 second.&lt;/P&gt;&lt;P&gt;Hope, my understanding is correct.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 14:54:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-dhms-is-calculating-hours-minutes-and-seconds/m-p/874984#M345724</guid>
      <dc:creator>Moksha</dc:creator>
      <dc:date>2023-05-10T14:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: How dhms is calculating hours, minutes and seconds?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-dhms-is-calculating-hours-minutes-and-seconds/m-p/874985#M345725</link>
      <description>&lt;P&gt;Datatime values are number of seconds since the start of 1960.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is just when you format it for display using something like the DATETIME format that the concept of days or hours or minutes comes into play.&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 14:56:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-dhms-is-calculating-hours-minutes-and-seconds/m-p/874985#M345725</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-05-10T14:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: How dhms is calculating hours, minutes and seconds?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-dhms-is-calculating-hours-minutes-and-seconds/m-p/875001#M345730</link>
      <description>&lt;P&gt;Correct, though actually running the code should have been to confirm what you expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The behavior of the DHMS and the related MDY functions is a bit more flexible than sometimes expected. I had what I thought was an odd value when doing some conversion from some old files with a date value that was out of order. The records were very intermittent dates and could go a fair amount of time between measures but the records were supposed to be sequential. After reading the source file using the MDY function to build the dates one was out of order. The Day value was 67. So a November date, that likely should have been either 6 or 7 became one in January of the next year.&lt;/P&gt;
&lt;P&gt;Part of the fun with ETL processes. Trying to track down the correct date on a file that originated as manual data entry 20 years earlier was entertaining.&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 15:39:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-dhms-is-calculating-hours-minutes-and-seconds/m-p/875001#M345730</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-10T15:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: How dhms is calculating hours, minutes and seconds?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-dhms-is-calculating-hours-minutes-and-seconds/m-p/875003#M345732</link>
      <description>&lt;P&gt;Thank you.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, the dhms() and mdy() functions results for some values are little bit tricky.&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 15:45:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-dhms-is-calculating-hours-minutes-and-seconds/m-p/875003#M345732</guid>
      <dc:creator>Moksha</dc:creator>
      <dc:date>2023-05-10T15:45:48Z</dc:date>
    </item>
  </channel>
</rss>

