ODD DATE & TIME (FORMAT) CALCULATION

CeeGee96

New Member
Joined
Jul 23, 2023
Messages
4
Office Version
  1. 365
  2. 2021
  3. 2019
Platform
  1. Windows
Greetings lifesaving gurus šŸ˜Š

It has been a long time since Iā€™ve been here and/or done anything exciting with Excel, and Iā€™ve forgotten quite a lot ā˜¹ However I know you guys & gals are unmatchable, therefore: help please!

At work we use an uncommon format for the date and time of DDHHMM and month MMM (known as a DTG) It is standard in our area of work, but probable not much elsewhere and as Excel doesnā€™t know what a DTG is I use hidden formula to build it into something Excel will recognise.

My problem stems from calculating the days, hours and minutes between date/times, despite Excel recognising a ā€œconstructedā€ date and time i.e. dd/mm/yy hh:mm I cannot get the formula(s) Iā€™ve tried to calculate correctly for every line of data;

As an example, it is okay with 02/02/23 10:17 to 02/02/23 10:27 It knows that is 10 minutes. However, it doesnā€™t like 02/02/23 09:18 to 05/02/23 08:00 which it seems to think is 1095 days, 22 hours and 42 minutes apart.

And it certainly doesnā€™t like calculating from 24/02/23 09:10 to 12/03/23 09:17

My system will not let me upload the spreadsheet as an example however I will include a screenshot, and what formula I am trying at the moment

Finally, much as I like Macro, I cannot use them in this project as work are paranoid about the vulnerability of coding (sadly).



FORMULA BEING TRIED:

(column) P formula :

INT(V18-U18)&" days "&TEXT(V18-U18,"h"" hrs ""m"" mins """)

(column) S:

MONTH(B18)

(column) U:

TEXT((DATE($A$2,$S18,LEFT($N18,2))),"dd/mm/yy")&" "&TEXT((TIME(MID($N18,3,2),RIGHT($N18,2),0)),"h:mm")

(column) V:

IF(LEFT(O18,2)<LEFT(N18,2),TEXT((DATE($A$2,($S18+1),LEFT($O18,2))),"dd/mm/yy")&" "&TEXT((TIME(MID($O18,3,2),RIGHT($O18,2),0)),"h:mm"),TEXT((DATE($A$2,$S18,LEFT($O18,2))),"dd/mm/yy")&" "&TEXT((TIME(MID($O18,3,2),RIGHT($O18,2),0)),"h:mm"))



Thank you in anticipation!
 

Attachments

  • data.png
    data.png
    19.5 KB · Views: 21
  • data.png
    data.png
    27.9 KB · Views: 20

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Are the examples in your first screen capture accurate? Based on your description I'm not seeing anything in the DTG column that tells us which month is referred to which is going to be a necessity looking at the first two rows.
 
Upvote 0
did you try using the =DATEDIF() function instead of =INT(V18-U18)? Also, as a test create two adjacent cells, copy the contents of Cells V18, and U18 and format the value as a number to make sure the two serial date values make sense.
 
Upvote 0
I thought I was missing something simple so came back and had another look. See if this does what you need it to (based on the second screen capture in your original post).

Cell Formulas
RangeFormula
R18:S22R18=IFERROR(EOMONTH($B18,-1)+LEFT(N18,2)+REPLACE(RIGHT(N18,4),3,0,":"),"")
P19:P22P19=IFERROR(INT(S19-R19) &" Days, "&TEXT(S19-R19,"h"" hrs ""m"" mins """),"")
 
Upvote 0
Are the examples in your first screen capture accurate? Based on your description I'm not seeing anything in the DTG column that tells us which month is referred to which is going to be a necessity looking at the first two rows.
sorry, ignore the first screen shot, I did upload it and then browser crashed, when I reposted it wasnt there until I submitted the second time
 
Upvote 0
did you try using the =DATEDIF() function instead of =INT(V18-U18)? Also, as a test create two adjacent cells, copy the contents of Cells V18, and U18 and format the value as a number to make sure the two serial date values make sense.
I have tried datedif. ALos various formats, incuding the standard offering and custom ones :(
 
Upvote 0
I thought I was missing something simple so came back and had another look. See if this does what you need it to (based on the second screen capture in your original post).

Cell Formulas
RangeFormula
R18:S22R18=IFERROR(EOMONTH($B18,-1)+LEFT(N18,2)+REPLACE(RIGHT(N18,4),3,0,":"),"")
P19:P22P19=IFERROR(INT(S19-R19) &" Days, "&TEXT(S19-R19,"h"" hrs ""m"" mins """),"")
This works unless the end date/time is in the next month, but I thik I can look at and hopefully solve that one, thank you Jasonb 75 it has given me a solution, hopefully.
 
Upvote 0
How would we identify that from the data that we have to work with? I couldn't see anything in the samples that shows if it is a different month.
 
Upvote 0
@ CeeGee96: Try using the following formulas in Columns U and V, respectively:
Excel Formula:
=DATE($A$2,MONTH($B18),LEFT($N18,2))+REPLACE(RIGHT($N18,4),3,0,":")
=DATE($A$2,MONTH($B18)+(LEFT($O18,2)<LEFT($N18,2)),LEFT($O18,2))+REPLACE(RIGHT($O18,4),3,0,":")
 
Upvote 0

Forum statistics

Threads
1,215,068
Messages
6,122,950
Members
449,095
Latest member
nmaske

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