Informat (ParseDate) function with timeHi,
I have a question about Informat function (or its alias ParseDate). If I have a string with date and time information, and I try to parse date on JMP 15.2.0.
str="2022-10-22 16:25:37";
datetime= Informat( str, "yyyy-mm-dd HH:mm:ss" );
show(type(datetime));
show(datetime);
I get output different kind of outputs, depending on date time settings (Win 10).
Regional format English (United Kingdom):
str = "2022-10-22 16:23:37";
Type(datetime) = "Date";
datetime = 22Oct2022:16:23:37;
Or Regional format Finnish (Finland):
str = "2022-10-22 16:23:37";
Type(datetime) = "Number";
datetime = .;
Is there a function that could parse time also? Or are there suggestions how this could be done?
Mass CustomizationWindowsRe: Informat (ParseDate) function with timeThank you, this example works for the datetime settings tested.
Re: Informat (ParseDate) function with timeI have used << Use Locale() to overcome issues with date and time formats. The example you provided did not solve issue, I think that I come back to this later when I have time (pun intended). The issue with the example is most probably solved with << Use Locale(). I'll also try Format Pattern, if I get newer version of the JMP.
Thanks again sharing your knowledge.
Re: Informat (ParseDate) function with timeHere is one way to handle the issue
str="2022-10-22 16:25:37";
datetime = datemdy(num(word(2,str," -:")),
num(word(3,str," -:")),
num(word(1,str," -:")) ) +
3600*num(word(4,str," -:")) +
60 * num(word(5,str," -:")) +
num(word(6,str," -:")
);
show(format(datetime,"m/d/y h:m:s"));
It shows in the log
Format(datetime, "m/d/y h:m:s") = "10/22/2022 4:25:37 PM";
Re: Informat (ParseDate) function with timeCheck out if using << Use Locale() helps at all.
JMP was fairly bad at managing managing time (and dates) before JMP16. I would most likely parse the string to year, month, day, hour, minute and second. Then sum those to get date_time. With JMP16 you could most likely just use Format Pattern
Maybe this can give some ideas:
Names Default To Here(1);
str = "2022-10-22 16:25:37";
date = Word(1, str, " ");
time = Word(2, str, " ");
y = Num(Word(1, date, "-"));
m = Num(Word(2, date, "-"));
d = Num(Word(3, date, "-"));
time_separator = Left(Regex(Format(Today(), "h:m:s"), "\d", "", GLOBALREPLACE), 1);
hh = Num(Word(1, time, time_separator));
mm = Num(Word(2, time, time_separator));
ss = Num(Word(3, time, time_separator));
date_time = Date DMY(d, m, y) + hh * 60 * 60 + mm * 60 + ss;
AsDate(date_time);
Re: Informat (ParseDate) function with timeIt seems that in Jmp 15.2 Informat just ignored fancy patterns like
datetime= Informat( str, "yyyy-mm-dd HH:mm:ss" );
Even pattern = "hello" results in

In later versions, Jmp will tell the user:
Unknown format: hello
What works:
Informat with the option Format Pattern:
str="2022-10-22 16:25:37";
datetime= Informat( str, "Format Pattern", "<YYYY><MM><DL><DD> <HH><:><MM><:><SS>" );
show(type(datetime));
show(datetime);</SS></MM></HH></DD></DL></MM></YYYY>