- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Extract hours to the nearest hours from duration ( hour:min) format
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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Extract hours to the nearest hours from duration ( hour:min) format
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Extract hours to the nearest hours from duration ( hour:min) format
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 )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Extract hours to the nearest hours from duration ( hour:min) format
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- 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"));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- 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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Extract hours to the nearest hours from duration ( hour:min) format
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Extract hours to the nearest hours from duration ( hour:min) format
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 )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Extract hours to the nearest hours from duration ( hour:min) format
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.