cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. EST on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
JMP_9006
Level I

Extract Part of the String

Hello,

 

I have a string and I want to extract everything but the last four characters of the string. 

 

So, the following string,

 

12/9/2023 19:05:57:754

 

would results in,

 

12/9/2023 19:05:57

 

How do I do this in JMP

3 REPLIES 3
hogi
Level XIII

Re: Extract Part of the String

myString="12/9/2023 19:05:57:754";
length=Length(myString);
Substr("12/9/2023 19:05:57:754", 1,length-4)
JMP_9006
Level I

Re: Extract Part of the String

Thank you. It works!

jthi
Super User

Re: Extract Part of the String

Other simple option is to use Left() 

Names Default To Here(1);

str = "12/9/2023 19:05:57:754";
res = Left(str, Length(str) - 4);

and if you really want to get the date and time without milliseconds (not string without last 4 characters) you can also use Word

Names Default To Here(1);

str = "12/9/2023 19:05:57:754";
res = Word([1 -2], str, ":");

or left with contains to get last ":"

Names Default To Here(1);

str = "12/9/2023 19:05:57:754";
res2 = Left(str, Contains(str, ":", -1) - 1);
-Jarmo

Recommended Articles