BookmarkSubscribe
Choose Language Hide Translation Bar

## 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! 2 ACCEPTED SOLUTIONS

Accepted Solutions

## 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
Highlighted  Jeff_Perkinson 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. 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 8

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

The column names in the diagram should be
yyyymmdd hh:mm

## 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
Highlighted  Jeff_Perkinson 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. This one uses Informat() to convert the date and time values.

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

-Jeff

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

## 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! ## 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

## 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

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