Excel formula time subtract time in text format - excel

I want to subtract the time in text format
like: 10.51 - 2.15 (means 10hrs 51min - 2hrs 15min)
Now I using Min-Min and then convert to Hrs in text format, but have any wonderful code that I no need convert to Min? just Hrs-Hrs.
=CONCATENATE(INT((textMin)/60),".",MOD(INT(textMin),60))
I don't use time format or ":" because have a lot data to key in, number pad is good for key in much data.
Thanks a lot!

Several ways to approach this.
Use Find and Replace to replace . with :, then use simple subtraction
leave the data as you input it and use a formula to convert the decimals into time values
=TIME(INT(A1),MOD(A1,1)*100,0)-TIME(INT(B1),MOD(B1,1)*100,0)
like here:
Or use
=SUBSTITUTE(A1,".",":")-SUBSTITUTE(B1,".",":")

Related

Problem to get the difference of two timestamps in seconds in MS EXCEL

The Problem:
I got two timestamps in Excel (German version) in this format:
2023-01-28-10.14.20.123456
2023-01-29-11.15.21.123456
and I need the difference of these two timestamps in seconds - which would be 90061.
What I tried:
To define a custom format for the timestamp:JJJJ-MM-TT-hh.mm.ss
To define a custom format for the timestamp:JJJJ-MM-TT-hh.mm.ss.000000 but I cannot define the .000000 for the nanoseconds because I get an Excel error that this format cannot be used
To use following formula =TEXT(D6-C6;"[mm]")
I tried to use the formula in this post which translates to =DATWERT(LINKS(C6;10))+ZEITWERT(TEIL(C6;12;8))-DATWERT(LINKS(D6;10))+ZEITWERT(TEIL(D6;12;8))
Nothing worked so far - any hints are appreciated - Thanks in advance
Or, a slightly shorter formula
i.e.
=86400*(VALUE(REPLACE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A3,"-","/"),".",":",1),".",":",1),11,1," "))-VALUE(REPLACE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,"-","/"),".",":",1),".",":",1),11,1," ")))
or, auf Deutsch
=86400*(WERT(ERSETZEN(WECHSELN(WECHSELN(WECHSELN(A3,"-","/"),".",":",1),".",":",1),11,1," "))-WERT(ERSETZEN(WECHSELN(WECHSELN(WECHSELN(A2,"-","/"),".",":",1),".",":",1),11,1," ")))
(changing the UI language doesn't update the , with ; though)
So, brutally long, but works based on what you gave.
I assume that that format and the number of characters will not change.
((LEFT(A3,10)-LEFT(A2,10))*86400)+(HOUR(TIME(MID(A3,12,2)-MID(A2,12,2),MID(A3,15,2)-MID(A2,15,2),MID(A3,18,2)-MID(A2,18,2)))*3600)+(MINUTE(TIME(MID(A3,12,2)-MID(A2,12,2),MID(A3,15,2)-MID(A2,15,2),MID(A3,18,2)-MID(A2,18,2)))*60)+(SECOND(TIME(MID(A3,12,2)-MID(A2,12,2),MID(A3,15,2)-MID(A2,15,2),MID(A3,18,2)-MID(A2,18,2))))+((MID(A3,21,6)-MID(A2,21,6))*1000)
One way to reduce it is to put the time calculation used in hour, minute and second into a separate cell.

In MS Excel, how can you convert mm.ss into mm:ss?

Is there a way to convert a time in the format mm.ss into mm:ss?
For example, I have an entire column going down:
12.37,
1.34,
5.36
I want it to say:
00:12:37,
00:01:34,
00:05:36
I've tried using the find/replace tool on Excel, but since the values are formatted as "number" rather than duration, changing them ends up changing it into some kind of larger value.
Is there a way to just replace . to : and turn my numbers into a duration format?
Thanks!
use:
=--("00:"&SUBSTITUTE(A1,".",":"))
Then format the output as hh:mm:ss

How to parse string timestamp into date

I have a text value that looks like this: 2019-03-25T06:05:00-07:00. The general format is yyyy-mm-ddThh:mm:ss-GMT. I don't care about the GMT part. I am trying to use this text field to make time series scatter plots in excel.
I want to convert it to a timestamp as simply as possible. I currently do this using a bunch of formulas:
Input: 2019-03-25T06:05:00-07:00
Extract parts of time individually: =value(mid(input_cell,12,2))
Use date() and time() to get timestamp types
Add them together per this answer: https://stackoverflow.com/a/41164517/11163122
Use custom formatting to get a timestamp value
Output: 3/25/2019 6:05:00 AM
In total this took me 8 cells and custom formatting. This is too complicated. What is a simpler/more elegant way to do this?
You can use:
=--REPLACE(LEFT(A1,19),11,1," ")
and format as desired
Turns out the timestamp type is ISO 8601: https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations
This led me to this answer: https://stackoverflow.com/a/26315881/11163122
Using the formula there, I found this to be a sufficient solution. If anyone out there has a better method, please speak up! :)

Converting 1m 51s to a format recognized by Excel as a time

I'm trying to convert a string to a time format in excel. The data is displayed as 2m 51s, 0m 4s, and so on. I'd like to convert this into 2:51 and so on and also would like to be able to pivot the data using those numbers as values. I tried a simple find and replace to remove the m and s and add in a : but it doesn't work when I need to pivot the data as Excel considers that as a date.
You can use
=TIME(0,LEFT(A1,(FIND("m",A1,1)-1)),MID(LEFT(A1,FIND("s",A1)-1),FIND("m",A1)+1,LEN(A1)))
Depending on your settings it may give you an AM/M time but you can change the cell formatting to 'Time' to get 00:02:51.
With data in E1, in F1 enter:
=TIMEVALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE("00:" & E1," ",""),"m",":"),"s",""))
and apply proper formatting:
The formula takes a string like:
1m 51s
and converts it into:
0:1:51
this is then processed by the TIMEVALUE() function.

Excel if formula possibility

I have an issue that I don't personally know how to format. I need to subtract numbers that are in seconds, formatted to be viewed as 58.43 or 59.99, but that are sometimes in minutes, formatted as 1:01.33 for example.
I would also need to be able to subtract the numbers from each other to be recognized as (+1.08) or (-0.78), with the parentheses.
I'm sure I can elaborate somewhere, so let me know if this doesn't make any sense. Thanks
It depends if 58.43 is formatted as a number or time. Date and time are stored in number of days, so the time 58.43 is actually stored as the number 0.00067627314814814800000 (58.43/24/60/60).
If both values are time values, then the custom number format of the result can be:
(+s.00);(-s.00);(0.00);#
To handle both cases, instead of =A1-A2 you can try this something like this:
=IF(A1<1,A1,A1/86400)-IF(A2<1,A2,A2/86400)
If those are just time values formatted as mm.ss then you can use TIMEDIFF()
https://support.office.com/en-us/article/Calculate-the-difference-between-two-times-e1c78778-749b-49a3-b13e-737715505ff6
If not, try to convert them to time values and than use TIMEDIFF()
The first part is straightforward
Apply a default format of
ss:00
Then in conditional formatting use a formula
=A2>=TIME(0,1,0)
and apply a format of
m:ss.00
for the ones that are a minute or more.
There is no direct solution to the problem of displaying negative times short of changing the default date system used by Excel as you can see in a number of references. The only way to do it here is to test whether the result is positive or negative and display the positive difference with or without a minus sign.
=IF(B2>=A2,TEXT(B2-A2,"(+s.00)"),TEXT(A2-B2,"(-s.00)"))
The downside of this is that they are actually text values and you can't use them in any further calculations. However the results of A2-B2 are still good even if you can't display them directly, so you can use A2-B2 in subsequent formulae if you want to even if it is negative.

Resources