BookmarkSubscribeRSS Feed
lwx228

Regular Contributor

Joined:

Aug 14, 2018

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

Joined:

Jun 22, 2012

Solution

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
Jeff_Perkinson

Community Manager

Joined:

Jun 23, 2011

Solution

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
8 REPLIES
lwx228

Regular Contributor

Joined:

Aug 14, 2018

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

Joined:

Jun 22, 2012

Solution

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
Jeff_Perkinson

Community Manager

Joined:

Jun 23, 2011

Solution

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
lwx228

Regular Contributor

Joined:

Aug 14, 2018

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.
lwx228

Regular Contributor

Joined:

Aug 14, 2018

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

 

 

 

txnelson

Super User

Joined:

Jun 22, 2012

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
Jeff_Perkinson

Community Manager

Joined:

Jun 23, 2011

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
lwx228

Regular Contributor

Joined:

Aug 14, 2018

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")