How to split and expand date and hours?

Fractalis

Active Member
Joined
Oct 11, 2011
Messages
310
Office Version
  1. 2019
Platform
  1. Windows
Hi everyone,

How to split and expand the date and time with a formula or VBA?

I have the "start date and time" that begins in one date and sometimes ends in next day. For this cases I'd like to split in two
rows from begin date until same date up to 23:59 and continue in next row the next date until end hour. For the cases where start
date and end date is the same only split in one row.

Below is the input 2 columns with blue headers and output I'd like to get in green headers.

Start Date & TimeEnd Date & TimeStart DateStart TimeEnd DateEnd Time
10/13/2022 23:4410/14/2022 2:202022-10-1323:442022-10-130:59
10/24/2022 23:1710/24/2022 23:572022-10-140:002022-10-142:20
2022-10-2423:172022-10-2423:51


Thanks in advance.
 
Your post #10 is using text,. Access the date cell.
N.B. You can copy my post to a clean sheet and review the formulas. Click on the icon below the f(x) in the header , move to sheet and paste.
 
Upvote 0

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
I reposted the information showing the Date/Time with General Format.
You can format the Date/Time to your preference but do not convert to Text.
I included the seconds so that you see that the numbers add correctly.

Time.xlsm
ABCDE
1Start Date & TimeEnd Date & TimeTotalTime Start DayTime End Day
244847.989144848.097502:36:0500:15:4002:20:25
344858.970444858.998400:40:2400:40:2400:00:00
4
11a
Cell Formulas
RangeFormula
C2:C3C2=B2-A2
D2:D3D2=IF(INT(B2)>INT(A2),INT(B2)-A2,B2-A2)
E2:E3E2=IF(INT(B2)>INT(A2),MOD(B2,1),0)


Time.xlsm
ABCDE
1Start Date & TimeEnd Date & TimeTotalTime Start DayTime End Day
244847.989144848.097502:36:0500:15:4002:20:25
344858.970444858.998400:40:2400:40:2400:00:00
4
11a
Cell Formulas
RangeFormula
C2:C3C2=B2-A2
D2:D3D2=LET(x,INT(B2),IF(x>INT(A2),x-A2,B2-A2))
E2:E3E2=IF(INT(B2)>INT(A2),MOD(B2,1),0)
 
Last edited:
Upvote 0
My default settings for date is dd/mm/yy. Yours is mm/dd/yy. Pl check.
The dates may be in text fomat. Change it to date format.
If problem not solved, pl upload file.
 
Upvote 0
I reposted the information showing the Date/Time with General Format.
You can format the Date/Time to your preference but do not convert to Text.
I included the seconds so that you see that the numbers add correctly.

I copied as you suggested and I see the same output as you, but is different than the output I'm looking for :(
 
Upvote 0

Forum statistics

Threads
1,213,496
Messages
6,113,995
Members
448,539
Latest member
alex78

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