Convert time

GColeman

New Member
Joined
Feb 16, 2016
Messages
34
Office Version
  1. 2016
Platform
  1. Windows
Hello. I have a sheet that utilizes time in 24hr format. There are some time calculations that result in how many hours an employee has left to work, and displays it in the 24hr format.
Is there a way to split the value and add text to have the cell show "11hrs 30 mins" rather than "11:30"? Currently I can get it to show " You have 11 hrs and 01 mins left to work" but how do I get it to show 30 mins instead of the 01? I assume the "(D7,"mm")" is where the problem is.
I get that I may need to split the "11:30:00" imto multiple cells to pull the data from. I can do that through the data tab, but it doesn't seem to be dynamic (F9:G9). Or with a formula using LEFT, MID, RIGHT (F11) but I get #VALUE error when I try and do it with a number. I definately prefer something like the formula I have in F7 though.
 

Attachments

  • Time and text.JPG
    Time and text.JPG
    38 KB · Views: 29

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
And this is why I love this page.
Thank you.
I may have tagged it as fixed too soon. It doesn't work if the time remaining is over 24 hours. 25:30 gives an answer of "1 hours and 30 mins" As well, and less of an issue, it doesnt recognize :00 as minutes. 25:00 gives an answer of "1 hours and mins".
D7 is formatted [h]:mm:ss
 

Attachments

  • Time and text 2.JPG
    Time and text 2.JPG
    40.4 KB · Views: 21
Upvote 0
See if this works. If not what's the formula you have in D7.

Book1
BCDEF
7
82/20/2024 15:062/20/2024 8:4606:20You have 6 Hours and 20 min left to work
92/20/2024 11:002/20/2024 10:2600:34You have 0 Hours and 34 min left to work
102/20/2024 11:002/20/2024 10:0001:00You have 1 Hours and 0 min left to work
112/20/2024 1:002/19/2024 11:0014:00You have 14 Hours and 0 min left to work
122/20/2024 2:002/17/2024 13:152.53125You have 60 Hours and 45 min left to work
Sheet1
Cell Formulas
RangeFormula
D8:D12D8=B8-C8
F8:F12F8="You have " &TEXT(INT(IF(INT(D8)>=1,(INT(D8)*24)+HOUR(D8-INT(D8)),HOUR(B8-C8))),0)&" Hours and "&TEXT(MINUTE(D8),0)&" min left to work"
 
Upvote 0
Perhaps modify cell F7 like this:
Excel Formula:
="You have "&TEXT(INT(C7) * 24 + HOUR(C7),"#")&" hours and "&TEXT(MINUTE(C7),"0")&" mins left to work."
 
Upvote 0
@riv01 That is a shorter formula. You need to change the "#" in your formula to "0" so that it shows 0 hours as in F9.
Book1
BCDEF
92/20/2024 11:002/20/2024 10:2600:34You have 0 hours and 34 mins left to work.
Sheet1
Cell Formulas
RangeFormula
D9D9=B9-C9
F9F9="You have "&TEXT(INT(D9) * 24 + HOUR(D9),"0")&" hours and "&TEXT(MINUTE(D9),"0")&" mins left to work."
 
Upvote 0
@riv01 That is a shorter formula. You need to change the "#" in your formula to "0" so that it shows 0 hours as in F9.
Book1
BCDEF
92/20/2024 11:002/20/2024 10:2600:34You have 0 hours and 34 mins left to work.
Sheet1
Cell Formulas
RangeFormula
D9D9=B9-C9
F9F9="You have "&TEXT(INT(D9) * 24 + HOUR(D9),"0")&" hours and "&TEXT(MINUTE(D9),"0")&" mins left to work."
This one and the last solution both seem to work. I'll keep them both handy in case i run into other issues. Thank you for the help.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top