cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Choose Language Hide Translation Bar
chandankishor66
Level III

Conversion of AM/PM to 24 hrs format

Hello JMP user,

Can you please suggest how to convert the time AM/PM to 24 hrs format.

In below table, column 1 is in "Character" Data Type and I want to convert it in 24hrs (h:m:s) format. 

 

chandankishor66_0-1664360632850.png

Regards,

Chandan

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Conversion of AM/PM to 24 hrs format

If your data is always like that and you just want the hours, I would use formula with Word or Words and then just calculate the values together. One example below:

Num(Word(1, :Column 1)) + If(Word(2, :Column 1) == "PM", 12, 0);
-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Conversion of AM/PM to 24 hrs format

If your data is always like that and you just want the hours, I would use formula with Word or Words and then just calculate the values together. One example below:

Num(Word(1, :Column 1)) + If(Word(2, :Column 1) == "PM", 12, 0);
-Jarmo
Jeff_Perkinson
Community Manager Community Manager

Re: Conversion of AM/PM to 24 hrs format

@jthi gave you a good answer for exactly what you were looking to do. However, it's a good practice to use a store times in a time column. 

 

Learn more about how to do that: Using dates, times, datetimes and durations in JMP 

-Jeff