Splitting AM and PM hours from a Date Range

mcmuney

Board Regular
Joined
Sep 11, 2015
Messages
101
Office Version
  1. 365
I'm working on scheduling and I have a need to split AM and PM hours from a date range.

For example, lets say someone works a shift between 6AM and 2:30PM. Currently, the cell shows "0600-1430". I imagine it would be difficult to calculate from this value. Assuming yes, I can split the value into two different cells, FROM being 0600 and TO being 1430.

Once the above is done, what's the simplest way to determine how many AM and PM hours? The answer should be 6 AM hours and 2.5 PM hours.

Thanks in advance.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Try this

Book1
ABC
1DataFromto
20600-14306:0014:30
Sheet1
Cell Formulas
RangeFormula
B2B2=--TEXT(LEFT($A2,4),"00\:00")
C2C2=--TEXT(RIGHT($A2,4),"00\:00")
 
Upvote 0
Try this

Book1
ABC
1DataFromto
20600-14306:0014:30
Sheet1
Cell Formulas
RangeFormula
B2B2=--TEXT(LEFT($A2,4),"00\:00")
C2C2=--TEXT(RIGHT($A2,4),"00\:00")
Thank for that, but I'm actually trying to figure out how to go from here to calculating how many AM hours and PM hours there are in this time range.

The answer should be 6 AM hours and 2.5 PM hours. To be calculated from the time range.

Thanks. Let me know if I need to clarify further.
 
Upvote 0
Like this?

Book1
ABC
1DataAMFM
20600-143062.5
30600-07301.50
41300-153002.5
Sheet1
Cell Formulas
RangeFormula
B2:B4B2=MAX(0,MIN(12,TEXT(RIGHT($A2,4),"00\:00")*24)-TEXT(LEFT($A2,4),"00\:00")*24)
C2:C4C2=MAX(0,TEXT(RIGHT($A2,4),"00\:00")*24-MAX(12,TEXT(LEFT($A2,4),"00\:00")*24))
 
Last edited:
Upvote 0
Like this?

Book1
ABC
1DataAMFM
20600-143062.5
30600-07301.50
41300-153002.5
Sheet1
Cell Formulas
RangeFormula
B2:B4B2=MAX(0,MIN(12,TEXT(RIGHT($A2,4),"00\:00")*24)-TEXT(LEFT($A2,4),"00\:00")*24)
C2:C4C2=MAX(0,TEXT(RIGHT($A2,4),"00\:00")*24-MAX(12,TEXT(LEFT($A2,4),"00\:00")*24))
This is super! Thanks.

There's one scenario where it doesn't work: 2200-0630 (it shows 0 for both AM and PM)

Any reason for this?
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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