Subtracting two time inputs on a spreadsheet and performing a mathematical equation

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
563
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
In Cell A1 I have text Start Time and Cell A2 I have text Now. Cell B1 contains the start time (manually entered) and cell B2 contains the NOW() function. Cell B3 subtracts the difference between cells B2-B1. All that works as expected. Now the issue, I need to take the difference convert it to its decimal equilvalent (i.e. cell B2-B1=3:42 or 3.7) and multiply it by 60 to get its minute equivalent. How can I achieve this?

Also, I have this snippet of code to Autoupdate the now function but I can't get it to format the current time to 24 hour time.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column <> 1 Then Exit Sub
    If Target.Cells.Count > 1 Then Exit Sub
    With Target.Offset(0, 2)
        .Value = Now
        .NumberFormat = "HH:mm:ss"
    End With
End Sub

Thank You
 
Last edited:

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi,

Taking the following values as an example:
Cell B1 -> 05/12/2018 10:30:00
Cell B2 -> 06/12/2018 12:07:44

The difference in cell B3 will be -> =B2-B1, formatted as [hh]:mm:ss, which will give you a result of 25:37:44
Now if you want to convert this result to minutes, you can enter the following formula into cell B4 -> =VALUE(B3)*24*60 (format as "Number")

As for your code, this is surprising as I'd think that "HH:mm:ss" should already give you 24h format. In order to get AM/PM format, you'd need to use .NumberFormat = "HH:mm:ss AM/PM"
Can you give us an example or extract of your data?
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,384
Members
449,080
Latest member
Armadillos

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