Excel conert seconds dd hh mm ss for larger value - excel

I am trying to convert seconds to dd hh:mm:ss format
I am using the formula:
=A1/(24*60*60)
For 1099014 I get the result 12 17:16:54
For 2198028 I get the result 25 10:33:48
But for 3297042 I get the result 07 03:50:42
And the value for which I need the result is 7473837 and I get the result 26 12:03:57 which I suppose is not correct.
So why does the value fluctuates like this in excel and how can I exactly calculate the correct value?
Thank You

3,297,042 seconds represents 38 days 03:50:42
If you extend you format to have the whole date: yyyy MM dd hh:mm:ss
You'll see: 1900 02 07 03:50:42
That's why your format string gives you 07 03:50:42
Same thing for 7,473,837 where date is 1900 03 26 12:03:57
I might be wrong, but it seems there's no format (like [h] for hours) to tell excel to diplay number of days. Instead you could use:
=INT(A1/86400) & TEXT(A1/86400," hh:mm:ss")

Related

How to convert a time value from 22:30 to 1030p

I have multiple excel entries in 24 hour time format, that I need to convert to another very specific format.
e.g:
22:00 = 10p
6:00 = 6a
14:30 = 230p
You get the gist; I'm not sure as the length of the resulting time string is not always constant. I.e if the time ends in "00" it only has 2 or 3 characters. if it ends in anything else, it should have 4 or 5 strings
This converts to a new string value in a different cell.
Value to convert in cell A1
=TEXT(A1,IF(MINUTE(A1)=0,"ha/p","hmma/p"))
Examples:
22:00 10p
06:00 6a
6:00 6a
14:30 230p
Seems to work whether values are actual Excel times (eg 14:30:00) or strings eg '14:30.

In Excel I need to convert seconds in days hours min sec

I've already figure out that I can divide the number of seconds/86400 and then use the format: dd \d\a\y\s hh:mm:ss, but when it goes over 31 days 23:59:59, the number of days goes back to 0.
How can I keep on going with the days (like 32 days 00:00:01)?
Thank you
---- Adding more ---
I forgot to mention that I'm trying to do it in a Pivot table and I have not been able to figure out how to use text in it...
I've also found the following format but it won't give me a 00 in the month:
Nb of seconds: 13670
Format : yy \y\e\a\r\s MM \m\o\n\t\h\s dd \d\a\y\s hh:mm:ss
will give: 00 years 01 months 00 days 03:47:50
The time is ok but it should shows 00 months.
You can split your result by whole part and decimal part and operate with them:
=INT(A1/86400) & " " & TEXT((A1/86400)-INT(A1/86400),"hh:mm:ss")

Subtracting minutes from a timestamp in msexcel

I am extracting a timestamp from a cell in the format like Tue Nov 06 07:33:00 UTC 2018. Now, using vbscript code or vba code I want to subtract some minutes from the above mentioned timestamp. How can I achieve that?
split(split("Tue Nov 06 07:33:00 UTC 2018",":")(1),":")(0)
Will give you the minutes on their own. You can assign the splits to arrays, then rejoin with the correct minutes using `join
Something like so
Public Function addToTimeStamp(strTimeStamp As String, lngMinutes As Long) As String
Dim a() As String
a = Split(strTimeStamp, " ")
a(3) = DateAdd("n", lngMinutes, a(3))
addToTimeStamp = Join(a, " ")
End Function
Without going into VBA, you could separate the time stamp from the date, then work on the time stamp and adjust the date accordingly.
Assuming your dates are in the column A and that the timestamp always take the same structure, starting from row number 2
So first you create a column where there is only the time stamp, that is column B:
=MID(A2,FIND("UTC",A2)-9,8)
07:33:00
This first finds the position of "UTC" within the string then extract 8 characters starting from 9 characters to the left (accounting for the space between the time and "UTC").
Already there you can work on the minutes/hours/seconds.
Hours:
=NUMBERVALUE(LEFT(B2,2))
07
Minutes:
=NUMBERVALUE(Mid(B2,4,2))
33
Seconds:
=NUMBERVALUE(Right(B2,2))
00
You can also extract the date part of the time stamp using the same logic. Column C:
=MID(A2,FIND(B2,A2)-11,10)
Tue Nov 06
Finally you can also combine all of that into an Excel date and do your operations directly on the resulting number (This will ensure that you get a new valid date which account for incrementing/decrementing hours/days/months/years, it will also automatically account for leap years.)
Final date, including the time stamp, Column D:
=DATEVALUE(MID(A2,FIND(B2,A2)-3,2)&"-"&MID(A2,FIND(B2,A2)-7,3)&"-"&RIGHT(A2,4))+NUMBERVALUE(LEFT(B2,2))/24+NUMBERVALUE(MID(B2,4,2))/(24*60)+NUMBERVALUE(RIGHT(B2,2))/(24*60*60)
43410.3145833333
On this final number you can simply increase/decrease the number of minutes by adding it directly to it. The unit of this number is "days" so one minute is equal to 1/(24*60) and one hour is 1/24. Example of removing 33 minutes:
=D2 - 33/(24*60)
43410.2916666667
Changing the formatting to [dd/mm/yyyy hh:mm] will then result in:
06/11/2018 07:00:00

Excel time conversion from words

I was sent a spread sheet and it listed the times as "00 hours 04 minutes 44 seconds" how do i convert 00 hours 04 minutes 44 seconds into a regular time like 04:44 in excel?
Try this, assuming your data is in cell A1:
=RIGHT(LEFT(A1, FIND("hours", A1)-2), 2)&":"&RIGHT(LEFT(A1, FIND("minutes", A1)-2), 2)&":"&RIGHT(LEFT(A1, FIND("seconds", A1)-2), 2)
You can see what each individual piece is doing if you split it apart at the &. For example, =RIGHT(LEFT(A1, FIND("minutes", A1)-2), 2) returns "04". One level in from that, LEFT(A1, FIND("minutes", A1)-2) returns "00 hours 04", and you need the right two characters of that.
This should work regardless of what order the hours, minutes, and seconds are in.
The CGritton's solution shows the time as text (you can not change the format or do some calculation with it).
If all cells have the same format ## hours ## minutes ## seconds you can simplify the formula.
Assuming that you have "00 hours 04 minutes 44 seconds" in cell B4, just type, for example in cell D4:
=TIME(LEFT(B4,2),MID(B4,10,2),MID(B4,21,2))
Then you can change the format to: hh:mm:ss AM/PM or hh:mm AM/pm or hh:mm

Construct year-month-day hour:min:sec from encoded string

I have in a cell the following value 07DD0B190C3A00
I know that:
07DD is the year 2013
0B is the month November
19 is the date 25th
OC is the hour Noon
3A are the minutes 58
How can I translate this to 2013-11-25 12:58:00
Assumming the value is in A1, then this should work:
=HEX2DEC(LEFT(A1,4))&"-"&HEX2DEC(MID(A1,5,2))&"-"&HEX2DEC(MID(A1,7,2))&" "&HEX2DEC(MID(A1,9,2))&":"&HEX2DEC(MID(A1,11,2))&":"&HEX2DEC(MID(A1,13,2))

Resources