cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Instantly extract effect sizes, F-ratios, and FDR-adjusted p-values from your models with the Calculate Effects Sizes extension, available now in the JMP Marketplace!
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
Thierry_S
Super User

How to convert string into dates. Example: 06-AUG-2018 --> Date

Hi JMP community,

 

I would like to know if there is a more efficient way to translate a date string in the format 06-AUG-2018 into a JMP date.

 

Here is what I have used in the past:

Local( {t1},
	t1 = Match( Word( 2, :Date of Collection, "-" ),
		"JAN", 1,
		"FEB", 2,
		"MAR", 3,
		"APR", 4,
		"MAY", 5,
		"JUN", 6,
		"JUL", 7,
		"AUG", 8,
		"SEP", 9,
		"OCT", 10,
		"NOV", 11,
		12
	);
	Date MDY(
		t1,
		Num( Word( 1, :Date of Collection, "-" ) ),
		Num( Word( 3, :Date of Collection, "-" ) )
	);
)

Where "Date of Collection" is the string date.

I also tried the "In Format" function but I could not figure out how to make JMP understand the abbreviated month (e.g. JAN, FEB...).

 

Thank you for your help.

 

Sincerely,

 

TS

Thierry R. Sornasse
1 ACCEPTED SOLUTION

Accepted Solutions
Jeff_Perkinson
Community Manager Community Manager

Re: How to convert string into dates. Example: 06-AUG-2018 --> Date

Informat will work for you. No need to specify an input format.

 

d="06-AUG-2018";

d1="02-JAN-2016";

d2="08-DEC-1998";


x=informat(d);

x1=informat(d1);

x2 = informat(d2);

show(x, x1, x2);

/*:

x = 06Aug2018;
x1 = 02Jan2016;
x2 = 08Dec1998;
-Jeff

View solution in original post

1 REPLY 1
Jeff_Perkinson
Community Manager Community Manager

Re: How to convert string into dates. Example: 06-AUG-2018 --> Date

Informat will work for you. No need to specify an input format.

 

d="06-AUG-2018";

d1="02-JAN-2016";

d2="08-DEC-1998";


x=informat(d);

x1=informat(d1);

x2 = informat(d2);

show(x, x1, x2);

/*:

x = 06Aug2018;
x1 = 02Jan2016;
x2 = 08Dec1998;
-Jeff

Recommended Articles