How to convert long minutes to hours in excel - excel

I need a formula in excel to convert minutes to hours. Until now came the following formula:
=A1/1440
So, 180minutes its converted to 03:00, when formatted as hh:mm
But, i need also to convert long minutes, like 1600. In this case, the formula converts to 02:40, when it should show 26:40.
Any ideas?

You can try
=INT(A1/60)&":" &MOD(A1,60)
and =TEXT(FLOOR(A1/60,1),"00")&":"&TEXT(MOD(A1,60),"00") for Format hh:mm

Use exactly the same formula you are using now, but change the display format to:
[h]:mm:ss
That will display in the format you want AND allow you to perform operations on the values.
( With format showing in the top of the time columns)
[h]:mm:ss hh:mm:ss Equal?
=1600/1440 =1600/1440 =G23=F23
=F23+1600/1440 =G23+1600/1440 =G24=F24
Gives
[h]:mm:ss hh:mm:ss Equal?
26:40:00 2:40:00 TRUE
53:20:00 5:20:00 TRUE

Related

How can I format a string into a date: time format?

For example:
2021-08-18T22:24:49-06:00
I want to print this to a more readable format like: 8/18/21 10:24pm
I have tried using the built in DateTime function but it returns an error. Can someone point me in the right direction? I have checked other answers but they all relate to using the aforementioned funciton.
Looking at how your data is formatted and it seems your data is formatted "yyyy-mm-ddThh:mm:ss";so, here is my attempt:
Formula in C1:
=--SUBSTITUTE(LEFT(A1,16),"T"," ")
Then I just formatted the resulting datetime-stamp with:
m/d/yy hh:mm AM/PM
So it remains a numeric value to do your calculations with if needed.
Give a try to below formula-
=TEXT(FILTERXML("<t><s>"&SUBSTITUTE(A1,"T","</s><s>")&"</s></t>","//s[1]")+FILTERXML("<t><s>"&SUBSTITUTE(FILTERXML("<t><s>"&SUBSTITUTE(A1,"T","</s><s>")&"</s></t>","//s[2]"),"-","</s><s>")&"</s></t>","//s[1]"),"M/dd/yyyy hh:mm AM/PM")
The date is in ISO 8601 format. This will parse out the different parts of the date string and convert to a date, assuming that your string is in A1:
=DATEVALUE(LEFT(A1,10))
+TIMEVALUE(MID(A1,12,8))
+TIMEVALUE(RIGHT(A1, 5))
*INT(MID(A1, 20, 1) & 1)
The first part grabs the date, the second part grabs the time, the third part captures the date offset, and the last part captures the sign. If you want to format that, you can do it with the cell formatting or wrap it in TEXT:
=TEXT(
DATEVALUE(LEFT(A1,10))
+TIMEVALUE(MID(A1,12,8))
+TIMEVALUE(RIGHT(A1, 5))
*INT(MID(A1, 20, 1) & 1),
"yyyy-mm-dd hh:mm:ss"
)
Note that if you need to support UTC, that is indicated by Z instead of a time offset, and you would need to modify the formula slightly. If your data always has the same time offset, you could just hardcode it, instead of parsing it out.

How to change format of date and time format in excelwhich is combined

I have a date formate like 12-feb-17 07.54.34.340000000 AM to format 2/2/17 07:54 AM
How to convert to this using Excel?
the first 2 . need to be :. Use this formula and then format the result as desired:
=--SUBSTITUTE(SUBSTITUTE(A1,".",":"),":",".",3)

Converting Non-Time String into HH:MM

I have a Cell range that contains data in the following format:
1d 12h 37m
All Data is in this format but ranges from single to double digit values.
I need to try to convert this data as an ultimate goal into purely hh:mm
I am struggling with the conversion of this. The main issue arises when the number of digits varying between double and single digits.
I have the formula to extrapolate purely the numbers and remove the letters from this:
=SUM(ROUND(MOD(SMALL(IFERROR(ROW(OFFSET(A$1,,,LEN(A11)))+MID(A11,1+LEN(A11)-ROW(OFFSET(A$1,,,LEN(A11))),1)%, LEN(A11)+1), ROW(OFFSET(A$1,,,SUM(N(ISNUMBER(0+MID(A11,ROW(OFFSET(A$1,,,LEN(A11))),1))))))),1)*100,0)*(10^(ROW(OFFSET(A$1,,,SUM(N(ISNUMBER(0+MID(A11,ROW(OFFSET(A$1,,,LEN(A11))),1))))))-1)))&""
Ideally this needs to all be done as a formula but a VBA script is okay.
Any ideas?
You can use this formula to change to date/time:
=IFERROR(LEFT(A1,FIND("d",A1)-1),0)+TRIM(SUBSTITUTE(SUBSTITUTE(MID(A1,IFERROR(FIND("d",A1)+1,1),LEN(A1)),"h ",":"),"m",""))
Then either format it [hh]:mm which will return 36:37 or hh:mm which will return 12:37
=TEXT(((LEFT(A2,FIND("d",A2)-1))+((TRIM(MID(A2,FIND("d",A2)+1,FIND("h",A2)-FIND("d",A2)-1)))+((TRIM(MID(A2,FIND("h",A2)+1,FIND("m",A2)-FIND("h",A2)-1)))/60))/24),"[h]:mm")
This formula assumes a couple things:
"d", "h", "m" will always be present
You need Days converted to Hours
Explanation:
Days:
=(LEFT(A2,FIND("d",A2)-1))
Hours:
=(TRIM(MID(A2,FIND("d",A2)+1,FIND("h",A2)-FIND("d",A2)-1)))
Minutes:
=(TRIM(MID(A2,FIND("h",A2)+1,FIND("m",A2)-FIND("h",A2)-1)))
Combining:
=TEXT((<days>+(<hours>+(<minutes>/60))/24),"[h]:mm")
If you want it without Days converted to Hours, change "[h]:mm" to "hh:mm".

How to convert DD:HH:MM to HH:MM in Excel

I am facing a problem with excel.How can I convert DD:HH:MM to HH:MM in excel?
Here is an exmaple showcasing what I need.
1:02:49(1day, 2hours, 49 mins) should come as 26:49(26 hours, 49 min)
I'm guessing that your 1:02:49 cell is formatted as text; otherwise, you could just change the cell format from DD:HH:MM to HH:MM.
I've opted to output as text, but could change it to an actual Time value if needbe.
Yes, the formula is a bit long but it can cope with any number of digits between each :. So, for example, 100:3:4 (100 days, 3 hours, 4 minutes) would correctly evaluate to 2403:04
=24*LEFT(A1,FIND(":",A1)-1)+MID(A1,FIND(":",A1)+1,LEN(A1)-2-LEN(RIGHT(A1,LEN(A1)-FIND("#",SUBSTITUTE(A1,":","#",2))))-LEN(LEFT(A1,FIND(":",A1)-1)))&":"&TEXT(RIGHT(A1,LEN(A1)-FIND("#",SUBSTITUTE(A1,":","#",2))),"00")

Convert string to a epoch time in Excel

I am trying to convert string in following format: 20130817T140000Z(17th Aug 2013 at 14:00) to epoch time (seconds since 1970) in an MS Excel 2013.
Tried cell formatting, but it doesn't work with T and Z or the format in general.
This will convert your date into somethign Excel will understand, If you have your date in Cell A1, Then convert that into Epoch Time
=(DATE(LEFT(A1,4),MID(A1,5,2),MID(A1,7,2)) + TIME(MID(A1,10,2),MID(A1,12,2),MID(A1,14,2))-25569)*86400)
Try this:
A1=20130817T140000Z
A2=DATE(LEFT(A1,4),MID(A1,5,2),MID(A1,7,2))
A3=(DATEDIF("01/01/1970 00:00:00",A2,"D")+TIME(MID(A1,10,2),MID(A1,12,2),MID(A1,14,2)))*24*60*60
A1 is your input date as text, A2 is a formatted date, and A3 is a seconds difference between your date and epoch start date.
Useful link
Update: based on #user2140261 suggestions.
Assuming the string to convert is in cell B1 you can use the following with a custom format on the cell to get the date/time.
=DATE(MID(B1,1,4),MID(B1,5,2),MID(B1,7,2))+TIME(MID(B1,10,2),MID(B1,12,2),MID(B1,14,2))
The custom format is:
dd/mm/yyyy hh:mm:ss
This will get you the date with accuracy to the minute. You can follow the pattern to get seconds if necessary.
=DATE(VALUE(LEFT(A1,4)),VALUE(RIGHT(LEFT(A1,6),2)),VALUE(RIGHT(LEFT(A1,8),2)))+VALUE(RIGHT(LEFT(A1,11),2))/24+VALUE(RIGHT(LEFT(A1,13),2))/(24*60)
You could use this version to convert your string to Epoch time
=(TEXT(LEFT(A1,8)&MID(A1,10,6),"0000-00-00 00\:00\:00")-25569)*86400
This uses TEXT function to convert your string into a string that looks like a valid date/time - when you subtract 25569 (1/1/1970) that will co-erce that string to a valid date/time and the result can be multiplied by the number of seconds in a day to get Epoch time

Resources