<?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 separate DATE and TIME columns in formats YYYYMMDD and HHMMSS into a single column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Convert-separate-DATE-and-TIME-columns-in-formats-YYYYMMDD-and/m-p/53243#M30137</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I manage an addin for my company where all data is imported into JMP via command line utilities owned by our automation team. My addin translates a users request into a formatted command and issues the command in the background. The data is returned back as a text file on the users system. My addin can then load the data from the text file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue that I have is that the columns vary based on the users request. But, each table has a DATE (Format: YYYYMMDD) and TIME (Format: HHMMSS) column that are consistently there. I have not found a way to open a text file where I specify the&amp;nbsp;formats for some columns but let JMP interperet the data types for the rest.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The current implementation requires that I convert the DATE and TIME columns into character types, format the time into the HHMMSS with leading 0's, and then loop through the table to parse the DATE column into a date and convert the HH, MM, and SS parts into seconds so that I can add them to the DATE portion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();

:DATE &amp;lt;&amp;lt; Data Type(character);
:TIME &amp;lt;&amp;lt; Data Type(character);
:TIME &amp;lt;&amp;lt; Set Each Value(Repeat("0", 6-Length(:TIME))||:TIME);

dt &amp;lt;&amp;lt; New Column("DATETIME");
:DATETIME &amp;lt;&amp;lt; Format("m/d/y h:m:s");

For Each Row(
	:DATETIME[Row()] = Parse Date(:DATE[Row()], "YYYYMMDD") + 
	In Hours(Num(Substr(:TIME[Row()], 1, 2))) + 
	In Minutes(Num(Substr(:TIME[Row()], 3, 2))) + 
	Num(Substr(:TIME[Row()], 5))
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a cleaner way to join the DATE and TIME columns into a single DATETIME column?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Mar 2018 20:58:45 GMT</pubDate>
    <dc:creator>Picard</dc:creator>
    <dc:date>2018-03-15T20:58:45Z</dc:date>
    <item>
      <title>Convert separate DATE and TIME columns in formats YYYYMMDD and HHMMSS into a single column</title>
      <link>https://community.jmp.com/t5/Discussions/Convert-separate-DATE-and-TIME-columns-in-formats-YYYYMMDD-and/m-p/53243#M30137</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I manage an addin for my company where all data is imported into JMP via command line utilities owned by our automation team. My addin translates a users request into a formatted command and issues the command in the background. The data is returned back as a text file on the users system. My addin can then load the data from the text file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue that I have is that the columns vary based on the users request. But, each table has a DATE (Format: YYYYMMDD) and TIME (Format: HHMMSS) column that are consistently there. I have not found a way to open a text file where I specify the&amp;nbsp;formats for some columns but let JMP interperet the data types for the rest.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The current implementation requires that I convert the DATE and TIME columns into character types, format the time into the HHMMSS with leading 0's, and then loop through the table to parse the DATE column into a date and convert the HH, MM, and SS parts into seconds so that I can add them to the DATE portion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();

:DATE &amp;lt;&amp;lt; Data Type(character);
:TIME &amp;lt;&amp;lt; Data Type(character);
:TIME &amp;lt;&amp;lt; Set Each Value(Repeat("0", 6-Length(:TIME))||:TIME);

dt &amp;lt;&amp;lt; New Column("DATETIME");
:DATETIME &amp;lt;&amp;lt; Format("m/d/y h:m:s");

For Each Row(
	:DATETIME[Row()] = Parse Date(:DATE[Row()], "YYYYMMDD") + 
	In Hours(Num(Substr(:TIME[Row()], 1, 2))) + 
	In Minutes(Num(Substr(:TIME[Row()], 3, 2))) + 
	Num(Substr(:TIME[Row()], 5))
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a cleaner way to join the DATE and TIME columns into a single DATETIME column?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 20:58:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Convert-separate-DATE-and-TIME-columns-in-formats-YYYYMMDD-and/m-p/53243#M30137</guid>
      <dc:creator>Picard</dc:creator>
      <dc:date>2018-03-15T20:58:45Z</dc:date>
    </item>
  </channel>
</rss>

