<?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: Character to DateTime Conversion Help Needed in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Character-to-DateTime-Conversion-Help-Needed/m-p/607640#M80923</link>
    <description>&lt;P&gt;thanks jthi for your support. Will give this one a try as well - at least to learn better.&amp;nbsp;&lt;/P&gt;&lt;P&gt;thx again&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Mar 2023 21:50:42 GMT</pubDate>
    <dc:creator>altug_bayram</dc:creator>
    <dc:date>2023-03-02T21:50:42Z</dc:date>
    <item>
      <title>Character to DateTime Conversion Help Needed</title>
      <link>https://community.jmp.com/t5/Discussions/Character-to-DateTime-Conversion-Help-Needed/m-p/606434#M80841</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am attaching a sample single row table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Date1 column is character&amp;nbsp;&lt;/P&gt;&lt;P&gt;e.g. &lt;STRONG&gt;03-Mar-22 12.13 PM&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;ie. &lt;STRONG&gt;DD-MMM-YY HH.MM am/pm&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Date2 has a datetime format&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need a formula for especially Date1 to convert it into DateTime w/ desired format of&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;MM/DD/YYYY HH:MM:SS am/pm&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;(SS, seconds would be automatically zero )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My goal is to update a table based on a second one (or join) once I can 2 comparable datetime columns&amp;nbsp;&lt;/P&gt;&lt;P&gt;note: I tried some attempts, none worked so far. Appreciate the help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 16:32:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Character-to-DateTime-Conversion-Help-Needed/m-p/606434#M80841</guid>
      <dc:creator>altug_bayram</dc:creator>
      <dc:date>2023-06-08T16:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: Character to DateTime Conversion Help Needed</title>
      <link>https://community.jmp.com/t5/Discussions/Character-to-DateTime-Conversion-Help-Needed/m-p/606449#M80843</link>
      <description>&lt;P&gt;Here is one format that appears to work&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;monList = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
Informat(
	Char( Contains( monList, Word( 2, :Date1.Char, "-" ) ) ) || "/" || Word( 1, :Date1.Char, "-" ) || "/" || Word( 3, :Date1.Char, "-" ),
	"m/d/y h:m"
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The above JSL works only if the period in the time area of the data is changed to a semicolon.&lt;/P&gt;
&lt;P&gt;My suggestion is to use&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/3552"&gt;@brady_brady&lt;/a&gt;&amp;nbsp;solution below.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 08:29:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Character-to-DateTime-Conversion-Help-Needed/m-p/606449#M80843</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-03-02T08:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: Character to DateTime Conversion Help Needed</title>
      <link>https://community.jmp.com/t5/Discussions/Character-to-DateTime-Conversion-Help-Needed/m-p/606497#M80844</link>
      <description>&lt;P&gt;If you have JMP16+ you might be able to do this with Format Pattern&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_4-1677652317508.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/50558i12C4BC68BF336F56/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_4-1677652317508.png" alt="jthi_4-1677652317508.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other pattern is something like&amp;nbsp;&lt;EM&gt;&amp;lt;DD&amp;gt;-&amp;lt;MMM&amp;gt;-&amp;lt;YY&amp;gt; &amp;lt;hh&amp;gt;.&amp;lt;mm&amp;gt; &amp;lt;AMPM&amp;gt;&amp;nbsp;&lt;/EM&gt;and other&amp;nbsp;&lt;EM&gt;&amp;lt;MM&amp;gt;/&amp;lt;DD&amp;gt;/&amp;lt;YYYY&amp;gt; &amp;lt;hh&amp;gt;:&amp;lt;mm&amp;gt;:&amp;lt;ss&amp;gt; &amp;lt;AMPM&amp;gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2023 06:32:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Character-to-DateTime-Conversion-Help-Needed/m-p/606497#M80844</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-03-01T06:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: Character to DateTime Conversion Help Needed</title>
      <link>https://community.jmp.com/t5/Discussions/Character-to-DateTime-Conversion-Help-Needed/m-p/606688#M80855</link>
      <description>&lt;P&gt;Jim,&lt;/P&gt;&lt;P&gt;Where do I put this ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried it as a formula, did not work&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried entering this as "Set Format Pattern" (like jthi's suggestionb) and cannot enter more than one line.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use JMP 16&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2023 16:18:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Character-to-DateTime-Conversion-Help-Needed/m-p/606688#M80855</guid>
      <dc:creator>altug_bayram</dc:creator>
      <dc:date>2023-03-01T16:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: Character to DateTime Conversion Help Needed</title>
      <link>https://community.jmp.com/t5/Discussions/Character-to-DateTime-Conversion-Help-Needed/m-p/606712#M80859</link>
      <description>&lt;P&gt;I have JMP 16 and It did not work. Below are my steps. Would appreciate if you can point to a mistake.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First I put a formula (that was forgetten earlier) into&lt;/P&gt;&lt;P&gt;Date1.DateTimeFinalFormat = Date1.Char&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Set Date1.DateTimeFinalFormat date type/modeling to Numeric and Continuous&lt;/P&gt;&lt;P&gt;Set format to Format Pattern&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Uncheck "Use Output Format"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Set Format Pattern&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;lt;MM&amp;gt;/&amp;lt;DD&amp;gt;/&amp;lt;YYYY&amp;gt; &amp;lt;hh&amp;gt;:&amp;lt;mm&amp;gt;:&amp;lt;ss&amp;gt; &amp;lt;AMPM&amp;gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On Input side, Set Format Pattern&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;lt;DD&amp;gt;-&amp;lt;MMM&amp;gt;-&amp;lt;YY&amp;gt; &amp;lt;hh&amp;gt;.&amp;lt;mm&amp;gt; &amp;lt;AMPM&amp;gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;to which an error is issued:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="altug_bayram_0-1677691349121.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/50571iF6876668336EE4FF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="altug_bayram_0-1677691349121.png" alt="altug_bayram_0-1677691349121.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2023 17:24:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Character-to-DateTime-Conversion-Help-Needed/m-p/606712#M80859</guid>
      <dc:creator>altug_bayram</dc:creator>
      <dc:date>2023-03-01T17:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: Character to DateTime Conversion Help Needed</title>
      <link>https://community.jmp.com/t5/Discussions/Character-to-DateTime-Conversion-Help-Needed/m-p/606713#M80860</link>
      <description>&lt;P&gt;I also changed HH to hh and AMPM to ampm on input side..&amp;nbsp;&lt;/P&gt;&lt;P&gt;At one point, it accepts the format and then returns Date1.DateTime.FinalFormat column back to Character.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2023 17:26:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Character-to-DateTime-Conversion-Help-Needed/m-p/606713#M80860</guid>
      <dc:creator>altug_bayram</dc:creator>
      <dc:date>2023-03-01T17:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: Character to DateTime Conversion Help Needed</title>
      <link>https://community.jmp.com/t5/Discussions/Character-to-DateTime-Conversion-Help-Needed/m-p/606922#M80872</link>
      <description>&lt;P&gt;Hi Altug,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope you are well--it's been a long time!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am assuming you are doing this by scripting. JMP can handle many date and time formats natively. When this is the case, the Informat ( ) function is great, because it converts a string to a time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your date is pretty close to a native format. 03-Mar-22 12.13 PM is not a native format, but 03/Mar/22 12:13 PM is !&lt;/P&gt;
&lt;P&gt;So, all you need to change is your dashes to slashes&amp;nbsp; ( "-" becomes "/" ), and your period to a colon ( "." becomes ":" ).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Substitute ( ) command can do this for you. Once this is done, you can wrap that in an Informat ( ) to get a numeric date. All that remains is to apply your desired display format, which is a Locale format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the process is to write a new column that:&lt;/P&gt;
&lt;P&gt;a) has a formula that wraps an Informat ( ) around a Substitute ( ), and&amp;nbsp;&lt;/P&gt;
&lt;P&gt;b) formats the output to look like you want, while still retaining the numeric date underneath.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let us know how this goes,&lt;/P&gt;
&lt;P&gt;Brady&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Current Data Table();

dt &amp;lt;&amp;lt; New Column( "FixedDate",
	formula( Informat( 
		Substitute( :"date1.char"n, 
		"-", "/", 
		".", ":" 	
		)
	) ),
	&amp;lt;&amp;lt;Format( "Locale Date Time h:m:s", 23, 0 )
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="brady_brady_0-1677716077001.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/50592i43389ABC7002030E/image-size/large?v=v2&amp;amp;px=999" role="button" title="brady_brady_0-1677716077001.png" alt="brady_brady_0-1677716077001.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 00:35:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Character-to-DateTime-Conversion-Help-Needed/m-p/606922#M80872</guid>
      <dc:creator>brady_brady</dc:creator>
      <dc:date>2023-03-02T00:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: Character to DateTime Conversion Help Needed</title>
      <link>https://community.jmp.com/t5/Discussions/Character-to-DateTime-Conversion-Help-Needed/m-p/607069#M80886</link>
      <description>&lt;P&gt;I have had my fair share of issues with JMP and how it handles dates (&lt;STRONG&gt;and especially times&lt;/STRONG&gt;) when users have different settings on PC. JMP16+ have made it a bit better but they can still be very annoying to debug if users have different local settings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"Easiest" (and most robust) option is always (in my opinion) to build the datetime from scratch based on the situation. Get different parts of the date and time and then for example use Date MDY + calculation of time to get JMP datetime. After you have JMP's datetime you can then format it as needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could also trial and error and try to get the correct pattern first in script editor:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

datetime_str = "03-Mar-22 12.13 PM";
show(datetime_str);

datetime = In Format(
	datetime_str,
	"Format Pattern",
	"&amp;lt;DD&amp;gt;-&amp;lt;MMM&amp;gt;-&amp;lt;YY&amp;gt; &amp;lt;hh&amp;gt;.&amp;lt;mm&amp;gt; &amp;lt;AMPM&amp;gt;"
);

show(datetime);

datestr = Format(datetime, "Format Pattern", "&amp;lt;MM&amp;gt;/&amp;lt;DD&amp;gt;/&amp;lt;YYYY&amp;gt; &amp;lt;hh&amp;gt;:&amp;lt;mm&amp;gt;:&amp;lt;ss&amp;gt; &amp;lt;AMPM&amp;gt;");
show(datestr);

// If I couldn't get Format Pattern fairly quickly, I would just give up and write my own
// parser. Something like this might work
datetime_str = "03-Mar-22 12.13 PM";
months = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};

date_str = Word(1, datetime_str);
time_str = Word(2, datetime_str);
ampm_str = Word(3, datetime_str);

day_str = Word(1, date_str, "-");
month_str = Word(2, date_str, "-");
year_str = Word(3, date_str, "-");

day_num = Num(day_str);
month_num = Contains(months, month_str);
year_num = 2000 + Num(year_str);

hour_str = Word(1, time_str, ".");
minute_str = Word(2, time_str, ".");

minute_num= Num(minute_str);

hour_num = Num(hour_str);
If(ampm_str == "AM",
	if(hour_num == 12,
		hour_num -= 12;
	);
, ampm_str == "AM",
	if(hour_num == 12,
		hour_num = 12
	,
		hour_num += 12
	)
);

date_datetime = Date DMY(day_num, month_num, year_num);
time_datetime = In Hours(hour_num) + In Minutes(minute_num);

final_datetime = date_datetime + time_datetime;
As Date(final_datetime);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I have to play around with dates and times I will always try to go for ISO-format YYYY-MM-DD hh24:mm:ss as it at least has some hope of working and you know where the month is without being lucky.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 08:16:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Character-to-DateTime-Conversion-Help-Needed/m-p/607069#M80886</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-03-02T08:16:23Z</dc:date>
    </item>
    <item>
      <title>Re: Character to DateTime Conversion Help Needed</title>
      <link>https://community.jmp.com/t5/Discussions/Character-to-DateTime-Conversion-Help-Needed/m-p/607639#M80922</link>
      <description>&lt;P&gt;Brady,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's been long time and I hope you are doing well.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your technical solution certainly does well, as it did work great. In the end, it was so simple.&lt;/P&gt;&lt;P&gt;thanks again for your support.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 21:48:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Character-to-DateTime-Conversion-Help-Needed/m-p/607639#M80922</guid>
      <dc:creator>altug_bayram</dc:creator>
      <dc:date>2023-03-02T21:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: Character to DateTime Conversion Help Needed</title>
      <link>https://community.jmp.com/t5/Discussions/Character-to-DateTime-Conversion-Help-Needed/m-p/607640#M80923</link>
      <description>&lt;P&gt;thanks jthi for your support. Will give this one a try as well - at least to learn better.&amp;nbsp;&lt;/P&gt;&lt;P&gt;thx again&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 21:50:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Character-to-DateTime-Conversion-Help-Needed/m-p/607640#M80923</guid>
      <dc:creator>altug_bayram</dc:creator>
      <dc:date>2023-03-02T21:50:42Z</dc:date>
    </item>
    <item>
      <title>Re: Character to DateTime Conversion Help Needed</title>
      <link>https://community.jmp.com/t5/Discussions/Character-to-DateTime-Conversion-Help-Needed/m-p/607641#M80924</link>
      <description>&lt;P&gt;thx txnelson for your support&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 21:51:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Character-to-DateTime-Conversion-Help-Needed/m-p/607641#M80924</guid>
      <dc:creator>altug_bayram</dc:creator>
      <dc:date>2023-03-02T21:51:24Z</dc:date>
    </item>
  </channel>
</rss>

