Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jun 28, 2020 12:16 PM
(889 views)

Hi Guys

how to extract hours from the duration ( hr:min) formant and round the min into the hours

example:

15:26 : 15 hours and 26 min

I want : 15

16:38: 16 hours and 38 mins

I want :17 as 38 min is over 30 mins

Appreciate your help

3 ACCEPTED SOLUTIONS

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Thank you.

How to re format the round into hour only value i.e for 12 hours we want 12 not 12:00:00 to make it numeric value

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Go to the Column Info for the formula column and select a Format to use. Since there is not a direct format that will just display the Hour component of a time based column, you need to select a "Custom" format. The value you need to specify for the custom format is

`Hour( value )`

Jim

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

I took a different approach. I abandoned time and directly obtained hours. Here is the resulting table:

Here is the formula that I used.

I attached the modified data table for you.

Learn it once, use it forever!

6 REPLIES 6

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Extract hours to the nearest hours from duration ( hour:min) format

Here is how I do it

```
Names Default To Here( 1 );
time=informat("15:22:00","h:m:s");
show(format(round(time/inhours(1))*3600,"h:m:s"));
time=informat("10:49:00","h:m:s");
show(format(round(time/inhours(1))*3600,"h:m:s"));
```

Jim

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Extract hours to the nearest hours from duration ( hour:min) format

Thank you

Is there a way to do this without a script? I am not familiar with JMP programming but I run sas programming.

Is not then how to recode this with my actual variable name that is called "hours" and is in duration ( hr:min) formant. I would like to create a col hours1 and extract the hours and do the rounding?

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Extract hours to the nearest hours from duration ( hour:min) format

Attached is a data table with a time column and a formula column called Rounded that rounds the hours using the formula

`Round( :Time / In Hours( 1 ) ) * 3600`

Jim

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Thank you.

How to re format the round into hour only value i.e for 12 hours we want 12 not 12:00:00 to make it numeric value

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Go to the Column Info for the formula column and select a Format to use. Since there is not a direct format that will just display the Hour component of a time based column, you need to select a "Custom" format. The value you need to specify for the custom format is

`Hour( value )`

Jim

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

I took a different approach. I abandoned time and directly obtained hours. Here is the resulting table:

Here is the formula that I used.

I attached the modified data table for you.

Learn it once, use it forever!