<?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 Convert character variable to DateTime in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-character-variable-to-DateTime/m-p/209258#M15659</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all, I want to convert StartTime and EndTime which are character variable to datetime variable so I can do calculation.&amp;nbsp; Please see our they are structured in my data source.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.PNG" class="jive-image" height="79" src="https://communities.sas.com/legacyfs/online/10263_Capture.PNG" width="426" /&gt;&lt;/P&gt;&lt;P&gt;For example, the first row, I want my calculation to say that customer&amp;nbsp; started at 11:00 AM and ended 11:00 AM.&amp;nbsp; You are welcome to offer me another option of getting my desire calculation without any conversion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you ahead.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 04 May 2015 19:49:52 GMT</pubDate>
    <dc:creator>sdang</dc:creator>
    <dc:date>2015-05-04T19:49:52Z</dc:date>
    <item>
      <title>Convert character variable to DateTime</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-character-variable-to-DateTime/m-p/209258#M15659</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all, I want to convert StartTime and EndTime which are character variable to datetime variable so I can do calculation.&amp;nbsp; Please see our they are structured in my data source.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.PNG" class="jive-image" height="79" src="https://communities.sas.com/legacyfs/online/10263_Capture.PNG" width="426" /&gt;&lt;/P&gt;&lt;P&gt;For example, the first row, I want my calculation to say that customer&amp;nbsp; started at 11:00 AM and ended 11:00 AM.&amp;nbsp; You are welcome to offer me another option of getting my desire calculation without any conversion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you ahead.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 May 2015 19:49:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-character-variable-to-DateTime/m-p/209258#M15659</guid>
      <dc:creator>sdang</dc:creator>
      <dc:date>2015-05-04T19:49:52Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character variable to DateTime</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-character-variable-to-DateTime/m-p/209259#M15660</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can convert these type of text strings using the ANYDTDTM informat. Unfortunately it will not read the milliseconds. In the code below two methods are shown, one using the ANYDTDTM informat, the other uses a combination of two informats for the date and time part and then combine the date and seconds together using the DHMS function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; want;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; dateHave = &lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;"2015.03.03 11:19:41.440"&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; dateWant = input(dateHave, &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;anydtdtm19.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; dateWant2 = dhms(&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input(substr(dateHave, &lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;, &lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;10&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;), &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;yymmdd10.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , &lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , &lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , input(substr(dateHave, &lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;12&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;), &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;time16.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;)&lt;BR /&gt;&amp;nbsp; );&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; dateWant: &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;datetime22.3&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 May 2015 20:31:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-character-variable-to-DateTime/m-p/209259#M15660</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2015-05-04T20:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character variable to DateTime</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-character-variable-to-DateTime/m-p/209260#M15661</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, it was helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 May 2015 20:49:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-character-variable-to-DateTime/m-p/209260#M15661</guid>
      <dc:creator>sdang</dc:creator>
      <dc:date>2015-05-04T20:49:01Z</dc:date>
    </item>
  </channel>
</rss>

