cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
mystylelife19
Level III

How to convert 24 Hour into 12 Hour with AM/PM?

Hi Community,

 

I have data table with column TimeStamp 2023_10_04 02:22:24. Right now i already split the date & time into separate column using this script below:

Names Default To Here( 1 );
dt = Current Data Table();
dt << Text To Columns( delimiter( " " ), columns( :TimeStamp ) ); // in delimiter is SPACE

// Close the original timestamp column
dt << Delete Columns( "TimeStamp" );
dt << Delete Columns( "TimeStamp 1" );

But the format column still in 24 hour

mystylelife19_0-1696414048500.png

I want format 12 hour like this

mystylelife19_1-1696414134828.png

The problem is i have to use text to columns in excel if i want format 12 hour.

Can you please write me a script that can change all the row in columns into 12 hour format?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: How to convert 24 Hour into 12 Hour with AM/PM?

You might want to back up and not split the character data at all, just convert the original character time stamps into JMP date-time values.

Craige

View solution in original post

9 REPLIES 9
jthi
Super User

Re: How to convert 24 Hour into 12 Hour with AM/PM?

You could try using Format Pattern to create correct format for you. You can find it from column properties

jthi_1-1696415334543.png

 

jthi_0-1696415295501.png

 

-Jarmo
mystylelife19
Level III

Re: How to convert 24 Hour into 12 Hour with AM/PM?

Hi jthi,

 

I try to change into format 12 in column properties

mystylelife19_0-1696415873613.png

Turns out my time change into dot

mystylelife19_1-1696415916242.png

Please help,

jthi
Super User

Re: How to convert 24 Hour into 12 Hour with AM/PM?

Try out the different options that Format Pattern provides you with (it has explanation what each different option does).

jthi_0-1696416098946.png

 

-Jarmo
Craige_Hales
Super User

Re: How to convert 24 Hour into 12 Hour with AM/PM?

Craige_Hales
Super User

Re: How to convert 24 Hour into 12 Hour with AM/PM?

JMP's date-time values are numbers of seconds. The format determines how the number is displayed, but does not change the underlying numeric data stored in the data table.

Craige
Craige_Hales
Super User

Re: How to convert 24 Hour into 12 Hour with AM/PM?

The timestamp2 column contained character data before conversion. You'll need to convert it to numeric date-time data first by choosing both numeric and the proper format at the same time from the dialog. After that, you can change the format to have am/pm.

Craige
Craige_Hales
Super User

Re: How to convert 24 Hour into 12 Hour with AM/PM?

You might want to back up and not split the character data at all, just convert the original character time stamps into JMP date-time values.

Craige
mmarchandTSI
Level V

Re: How to convert 24 Hour into 12 Hour with AM/PM?

That will happen if your current column is character and you try to directly change to numeric with your output format pattern.  First, change the data type to numeric and apply the change.  All the values should become large whole numbers.  Then, set the format pattern as you did before.

 

mmarchandTSI_0-1696417841156.png

 

mystylelife19
Level III

Re: How to convert 24 Hour into 12 Hour with AM/PM?

Thankyou all, got it right now.

 

Best Regards,

mystylelife19