SOLVED

Converting numbers to time

Copper Contributor

I am working on building a railroad line's timetable.

 

In cell E7 is miles, H7 is speed, I7 is time to travel this distance, J7 is how long the time the train has traveled and L7 is the current time.

Going 62.8 miles at 35mph is 1.79 hours.  Time to travel is 1:48.  Total time should now add to 14:23 and the time should be, with time of prior stop at 13:53p plus 4 minutes for time at station plus 1:48 hours for travel time with next stop time should be 15:45p.  How do I make this work?  The TEXT(e7/h7,h.mm) function did not work so don't believe the additional calculations could be correct.

2 Replies
best response confirmed by Ktt03 (Copper Contributor)
Solution

@Ktt03  wrote:  ``TEXT(e7/h7,h.mm)``

 

I don't know why you are using the TEXT function.  But FYI, the posted syntax is incorrect.

 

The formula in I7 should be =E7/H7, formatted as General or Number if you want to see decimal seconds (1.79428571428571).

 

It should be =E7/H7/24, formatted as some form of time (e.g. Custom [h]:mm:ss.000) if you want to see Excel time (1:47:39.429).

 

If you want to see 1:48 for those numbers, I presume that you want to round time to the minute.  Two ways to do that:

 

=MROUND(E7/H7/24, "0:01")

or

=ROUND(1440*E7/H7/24, 0)/1440

 

formatted as Custom [h]:mm .

 

Caveat:  However, with those numbers, both formulas result in the exact binary approximation of 1:48, both formulas have the potential to be off by an infinitesimal difference.  Such differences might cause some comparisons to fail (e.g. MATCH, VLOOKUP).  If that matters to you, it is pruduent to explicitly round both formulas to the binary approximation of the Excel time.  For example:

 

=--TEXT(MROUND(E7/H7/24, "0:01"), "[h]:m")

 

-----

 

@Ktt03  wrote:  ``J7 is how long the time the train has traveled and L7 is the current time. [....] Total time should now add to 14:23 and the time should be, with time of prior stop at 13:53p plus 4 minutes for time at station plus 1:48 hours for travel time with next stop time should be 15:45p. How do I make this work?``

 

I do not fully understand.

 

If you are saying that L7 has the Excel time 13:57 and I7 has the Excel time 1:48, as calculated above, ostensibly the new formula (where?!) should be:

 

=L7+I7

 

formatted as Custom [h]:mm .

 

(Better:  the date should be included in L7, and the format should show the date.)

 

And again, if you might use the result of that formula with MATCH, VLOOKUP etc, it would be prudent to explicitly round to the binary approximation of the time, to wit:

 

if L7 has just time:  =--TEXT(L7+I7, "[h]:mm")

or

if L7 has date and time:  =INT(L7) + TEXT(MOD(L7,1)+I7, "[h]:mm")

 

INT(L7) extracts the date part.  MOD(L7,1) extracts the time part.  This more complicated formula should work regardless of the regional date form and syntax (e.g. MDY, DMY, YMD etc).

 

@Ktt03 

Perhaps like this

image.png

1 best response

Accepted Solutions
best response confirmed by Ktt03 (Copper Contributor)
Solution

@Ktt03  wrote:  ``TEXT(e7/h7,h.mm)``

 

I don't know why you are using the TEXT function.  But FYI, the posted syntax is incorrect.

 

The formula in I7 should be =E7/H7, formatted as General or Number if you want to see decimal seconds (1.79428571428571).

 

It should be =E7/H7/24, formatted as some form of time (e.g. Custom [h]:mm:ss.000) if you want to see Excel time (1:47:39.429).

 

If you want to see 1:48 for those numbers, I presume that you want to round time to the minute.  Two ways to do that:

 

=MROUND(E7/H7/24, "0:01")

or

=ROUND(1440*E7/H7/24, 0)/1440

 

formatted as Custom [h]:mm .

 

Caveat:  However, with those numbers, both formulas result in the exact binary approximation of 1:48, both formulas have the potential to be off by an infinitesimal difference.  Such differences might cause some comparisons to fail (e.g. MATCH, VLOOKUP).  If that matters to you, it is pruduent to explicitly round both formulas to the binary approximation of the Excel time.  For example:

 

=--TEXT(MROUND(E7/H7/24, "0:01"), "[h]:m")

 

-----

 

@Ktt03  wrote:  ``J7 is how long the time the train has traveled and L7 is the current time. [....] Total time should now add to 14:23 and the time should be, with time of prior stop at 13:53p plus 4 minutes for time at station plus 1:48 hours for travel time with next stop time should be 15:45p. How do I make this work?``

 

I do not fully understand.

 

If you are saying that L7 has the Excel time 13:57 and I7 has the Excel time 1:48, as calculated above, ostensibly the new formula (where?!) should be:

 

=L7+I7

 

formatted as Custom [h]:mm .

 

(Better:  the date should be included in L7, and the format should show the date.)

 

And again, if you might use the result of that formula with MATCH, VLOOKUP etc, it would be prudent to explicitly round to the binary approximation of the time, to wit:

 

if L7 has just time:  =--TEXT(L7+I7, "[h]:mm")

or

if L7 has date and time:  =INT(L7) + TEXT(MOD(L7,1)+I7, "[h]:mm")

 

INT(L7) extracts the date part.  MOD(L7,1) extracts the time part.  This more complicated formula should work regardless of the regional date form and syntax (e.g. MDY, DMY, YMD etc).

 

View solution in original post