I have had my fair share of issues with JMP and how it handles dates (and especially times) 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.
"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.
You could also trial and error and try to get the correct pattern first in script editor:
Names Default To Here(1);
datetime_str = "03-Mar-22 12.13 PM";
show(datetime_str);
datetime = In Format(
datetime_str,
"Format Pattern",
"<DD>-<MMM>-<YY> <hh>.<mm> <AMPM>"
);
show(datetime);
datestr = Format(datetime, "Format Pattern", "<MM>/<DD>/<YYYY> <hh>:<mm>:<ss> <AMPM>");
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);
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.
-Jarmo