subtract datetime in excel

2019-03-02 13:36发布

I'm trying to subtract two dates in two separate columns in excel, to find time difference. in h:mm format. The source format is the following.

11/18/2014 9:42:39 AM - 10/8/2014 12:17:13 PM

I have updated the columns to a date with the correct format.

When I subtract the two columns from eachother i get the following hh:mm value.

21:25

It seems to me that the calculation is not taking the dates into account.

What can i do to correct this?

2条回答
Animai°情兽
2楼-- · 2019-03-02 14:15

The calculation works correctly, but "hh" does not convert days to hours. Format the result as [h]:mm instead.

查看更多
我只想做你的唯一
3楼-- · 2019-03-02 14:28

Ok, the issue is that you need to convert the dates to number format, and then due the calculations.

Step 1) Convert both dates to numbers, with 4 decimal places

Step 2) Subtract the numbers, to give the time difference between the dates. The numbers before the decimal place are full days, and the numbers after the decimal place are hours, minutes, seconds, etc.

Step 3) Use =Mod(XX11,1)*24 to separate the hours, minutes, seconds from the days, and calculate the number of hours. Repeat for minutes, and seconds, as needed, using 60 instead of 24.

You will now have separate amounts of days, hours, minutes, etc. Put these together in a formula as necessary.

查看更多
登录 后发表回答