cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
tajrida
Level III

Formula to remove first three characters from a alpha-numeric string

HI,

 

How do I remove "Thu" from the alphanumeric string "Thu 01/02/2020 10:42 PM" using and assigning a formulae, to a column.

 

I tried using below formulas and it doesn't work. what am I doing wrong?

1. left

2. right

3. word

4. substr

Mohammed Ahmed
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Formula to remove first three characters from a alpha-numeric string

I created a new column and placed this formula in it.

Substr(:Preparation date, 5)

and it worked without issue.  See my attached file

 

Jim

View solution in original post

5 REPLIES 5
txnelson
Super User

Re: Formula to remove first three characters from a alpha-numeric string

If the column you are reading from is actually a character column, and not a numeric column with a format applied to it, then the substring is what you want to use.  Make sure the column is a character column. and if so, the below will work

a="Thu 01/02/2020 10:42 PM";

b=substr(a,5);

The formula version of the above code if the original column is called "MyColumn"

substr(:MyColumn,5);

If not then you just need to change the format for the column

 

 

Jim
tajrida
Level III

Re: Formula to remove first three characters from a alpha-numeric string

Your suggestion is working fine for other character columns in the table BUT not for the column with specific format i.e., 

a="Thu 01/02/2020 10:42 PM";

I also checked and verified column properties to ensure it is a "character" column. 

 

Mohammed Ahmed
txnelson
Super User

Re: Formula to remove first three characters from a alpha-numeric string

attach a sample data table please

Jim
tajrida
Level III

Re: Formula to remove first three characters from a alpha-numeric string

Thanks. Attached here is the test data file

Mohammed Ahmed
txnelson
Super User

Re: Formula to remove first three characters from a alpha-numeric string

I created a new column and placed this formula in it.

Substr(:Preparation date, 5)

and it worked without issue.  See my attached file

 

Jim