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
lwx228
Level VII

How to convert text format Numbers to yyyymmdd hh:mm format?

Hello, everyone!

How to use JSL or formula to convert the text of column 1 into the time format of column 2.

 

Thanks!

2018-11-30_22-27-38.png

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
txnelson
Super User

Re: How to convert text format Numbers to yyyymmdd hh:mm format?

Here is the formula for the conversion

Date DMY(
	Num( Substr( :date, 7, 2 ) ),
	Num( Substr( :date, 5, 2 ) ),
	Num( Substr( :date, 1, 4 ) ) ) + 
	60 * 60 * Num( Word( 2, :date, " :" ) ) + 
	60 * Num( Word( -1, :date, " :" ) )
Jim

View solution in original post

Highlighted
Jeff_Perkinson
Community Manager Community Manager

Re: How to convert text format Numbers to yyyymmdd hh:mm format?

@txnelson's formula will work but there's a slightly simpler formula that will work also.

 

JMPScreenSnapz300.png

This one uses Informat() to convert the date and time values. 

 

 

Informat( Word( 1, :Column 1 ) ) +Informat( Word( 2, :Column 1 ), "h:m" )

 

-Jeff

View solution in original post

8 REPLIES 8
lwx228
Level VII

Re: How to convert text format Numbers to yyyymmdd hh:mm format?

The column names in the diagram should be
yyyymmdd hh:mm
Highlighted
txnelson
Super User

Re: How to convert text format Numbers to yyyymmdd hh:mm format?

Here is the formula for the conversion

Date DMY(
	Num( Substr( :date, 7, 2 ) ),
	Num( Substr( :date, 5, 2 ) ),
	Num( Substr( :date, 1, 4 ) ) ) + 
	60 * 60 * Num( Word( 2, :date, " :" ) ) + 
	60 * Num( Word( -1, :date, " :" ) )
Jim

View solution in original post

Highlighted
Jeff_Perkinson
Community Manager Community Manager

Re: How to convert text format Numbers to yyyymmdd hh:mm format?

@txnelson's formula will work but there's a slightly simpler formula that will work also.

 

JMPScreenSnapz300.png

This one uses Informat() to convert the date and time values. 

 

 

Informat( Word( 1, :Column 1 ) ) +Informat( Word( 2, :Column 1 ), "h:m" )

 

-Jeff

View solution in original post

Highlighted
lwx228
Level VII

Re: How to convert text format Numbers to yyyymmdd hh:mm format?

Thanks!
Jim Let me know the principle, Jeff_Perkinson let me learn JMP function.
Highlighted
lwx228
Level VII

Re: How to convert text format Numbers to yyyymmdd hh:mm format?

How can JMP get the text of year, month and day from the date format?
Sorry to bother you again,Thank you!

 

2018-12-04_22-10-39.png

 

 

 

Highlighted
txnelson
Super User

Re: How to convert text format Numbers to yyyymmdd hh:mm format?

Your question is vague. Please give an example of what the input values looks like, and what you want the output value to be...….
Jim
Highlighted
Jeff_Perkinson
Community Manager Community Manager

Re: How to convert text format Numbers to yyyymmdd hh:mm format?

The Format() function is used to convert a JMP date, time or datetime value to a text string.

 

For example:

 

x=informat("20000214");

show(format(x, "m/d/y"));

show(format(x, "d/m/y"));

show(format(x, "Date Long"));

show(format(x, "Monddyyyy"));

Results in this in the log:

 

Format(x, "m/d/y") = "02/14/2000";
Format(x, "d/m/y") = "14/02/2000";
Format(x, "Date Long") = "Monday, February 14, 2000";
Format(x, "Monddyyyy") = "Feb142000";

 

 

-Jeff
Highlighted
lwx228
Level VII

Re: How to convert text format Numbers to yyyymmdd hh:mm format?

That's the style,Thanks!

The effect is the same:
format(x, "y/m/d")  ————    format(x, "yyyyymmdd")

Article Labels

    There are no labels assigned to this post.