BookmarkSubscribe
Choose Language Hide Translation Bar
Highlighted
Jaz
Jaz
Community Trekker

Time in Seconds to HH:MM:SS Format

Hi,

 

I have a column of seconds starting from 0 which increments by 1 second for each row. (0, 1, 2, 3, etc...). I was looking for a way to convert these times in seconds into a HH:MM:SS format. I came across this post: https://community.jmp.com/t5/Discussions/Date-Time-Format-Problem/td-p/52831 where a few ideas were suggested and I was wondering which approach would be the best to take. It doesn't have to work for the whole column, even being able to convert one time in seconds to the HH:MM:SS format would be useful. I want to do this solely using JSL.

 

Any help would be appreciated.

0 Kudos
3 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: Time in Seconds to HH:MM:SS Format

Just set the column format to one of the Duration formats available.  Go to Column Info for the column, and click on the down arrow beside the format and select Duration, and then choose which of the potential formats you want to use

Jim

Re: Time in Seconds to HH:MM:SS Format

Like Jim, I assumed that when you said that you had data in the form of seconds (time), that you entered it as a numeric value. It never occurred to me either that you would enter it as character data.

 

So following Jim's solution, first change the Data Type to Numeric and the Modeling Type to Continuous. Then continue with his detailed step-by-step instructions.

Learn it once, use it forever!
txnelson
Super User

Re: Time in Seconds to HH:MM:SS Format

Your code is not working because your syntax is incorrect.  You can find all of the correct syntax and examples in the Scripting Index

     Help==>Scripting Index

In your code, all of the issues are covered in the Data Table==>Column Scripting

jaz1.PNGJaz2.PNGJaz3.PNG

Jim
8 REPLIES 8
txnelson
Super User

Re: Time in Seconds to HH:MM:SS Format

Just set the column format to one of the Duration formats available.  Go to Column Info for the column, and click on the down arrow beside the format and select Duration, and then choose which of the potential formats you want to use

Jim
Jaz
Jaz
Community Trekker

Re: Time in Seconds to HH:MM:SS Format

Thanks but I can't seem to find format when in the column info dialogue box?

0 Kudos
txnelson
Super User

Re: Time in Seconds to HH:MM:SS Format

colinfo.PNG

colinfo2.PNG

Jim
Jaz
Jaz
Community Trekker

Re: Time in Seconds to HH:MM:SS Format

Screenshot (4).png

0 Kudos

Re: Time in Seconds to HH:MM:SS Format

Like Jim, I assumed that when you said that you had data in the form of seconds (time), that you entered it as a numeric value. It never occurred to me either that you would enter it as character data.

 

So following Jim's solution, first change the Data Type to Numeric and the Modeling Type to Continuous. Then continue with his detailed step-by-step instructions.

Learn it once, use it forever!
Jaz
Jaz
Community Trekker

Re: Time in Seconds to HH:MM:SS Format

Thanks, that worked. But I want to be able to script this change to duration. I clicked on Source>Edit but there seems to be no JSL for the duration change. I used the following code:

column(dt,"Stop Clock (seconds)")<<data type(Numeric)<<Modeling Type(Continuous)<<Format(Duration, hr:m:s); 

But it doesn't seem to work.

 

0 Kudos
txnelson
Super User

Re: Time in Seconds to HH:MM:SS Format

Your code is not working because your syntax is incorrect.  You can find all of the correct syntax and examples in the Scripting Index

     Help==>Scripting Index

In your code, all of the issues are covered in the Data Table==>Column Scripting

jaz1.PNGJaz2.PNGJaz3.PNG

Jim
Jaz
Jaz
Community Trekker

Re: Time in Seconds to HH:MM:SS Format

Thank you.

0 Kudos