cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Sign-in to the JMP Community will be unavailable intermittently Dec. 6-7 due to a system update. Thank you for your understanding!
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.
  • JMP 19 is here! Learn more about the new features.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
SpannerHead
Level VI

Convert number to time

I have a column of data that comes in as numerical values with either 7 or 8 digits and I need that in the HH,MM,SS format but everything I've tried yields failure.  Any obvious trick I'm missing?


Slán



SpannerHead
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Convert number to time

What is the number? What are the units?

View solution in original post

6 REPLIES 6

Re: Convert number to time

What is the number? What are the units?

SpannerHead
Level VI

Re: Convert number to time

Mark

 

One of the numbers is 61412.  I believe this represents 6:14:12AM.

 

 


Slán



SpannerHead
jthi
Super User

Re: Convert number to time

61412 has 5 digits, not seven or eight. Most likely you can convert your numbers? to strings and use informat with format pattern to turn it into a JMP datenum.

-Jarmo
SpannerHead
Level VI

Re: Convert number to time

I'm not good with numbers.  I was mixing up with the date information but that converted readily.


Slán



SpannerHead
jthi
Super User

Re: Convert number to time

Here is format pattern option, note that if your time is in 12-hour format, it will need some changes

InFormat(Right("0" || Char(:Column 1), 6), "Format Pattern", "<hh><:?><mm><:?><ss>")

jthi_0-1747973601379.png

 

-Jarmo

Re: Convert number to time

New Table( "Time",
	Add Rows( 2 ),
	New Column( "Time as Coded Number",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [61412, 142954] )
	),
	New Column( "Time",
		Numeric,
		"Continuous",
		Format( "h:m:s", 12, 0 ),
		Input Format( "h:m:s", 0 ),
		Formula(
			t1 = If( :Time as Coded Number < 100000,
				"0",
				""
			) || Char( :Time as Coded Number );
			In Hours( Num( Left( t1, 2 ) ) )
			+In Minutes( Num( Substr( t1, 3, 2 ) ) ) + Num( Right( t1, 2 ) );
		)
	)
)

You need a formula (or script) to convert the original 5 or 6 digits (assuming hh:mm:ss coding for a 24-hour clock) to the number of seconds (JMP's time base) and change the column format.

Recommended Articles