Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
KellyT
Level II

Parse Month (in 3 letter abbreviation) from Date Time

Hello,

 

I have a Date Time column containing dates in the following format of (dd/mm/yyy):

01/03/2017  

01/01/2017

01/12/2017

 

How can I use JSL to parse the month so that it would return:

Mar

Jan

Dec

 

Thank you so much for your help

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
KellyT
Level II

Re: Parse Month (in 3 letter abbreviation) from Date Time

Hi Craige, 

 

Thank you so much for the help. The original column was in a date time format.  So I ended up using the following JSL code:

 

dt <<  New Column("Month", Formula(Substr( Format( :Date Time, "ddMonyyyy" ), 3, 3 )));

View solution in original post

2 REPLIES 2
Highlighted
Craige_Hales
Staff (Retired)

Re: Parse Month (in 3 letter abbreviation) from Date Time

It is not clear if your column is a character column or a date-formatted numeric column. Here's a way to get the 3-letter month names from JMP without building a 12-item lookup table:

x=informat("01/12/2017","d/m/y"); // use this if the data is character, creates a date-time value
y=format(x,"ddMonyyyy"); // use this to get a string from a date time: "01Dec2017"
z=substr(y,3,3); // use this to pick out the month: "Dec"

You can also ask the date time value for the day, month, and year parts as numbers:  month(x), day(x), year(x).

 

Craige
Highlighted
KellyT
Level II

Re: Parse Month (in 3 letter abbreviation) from Date Time

Hi Craige, 

 

Thank you so much for the help. The original column was in a date time format.  So I ended up using the following JSL code:

 

dt <<  New Column("Month", Formula(Substr( Format( :Date Time, "ddMonyyyy" ), 3, 3 )));

View solution in original post

Article Labels

    There are no labels assigned to this post.