简体   繁体   中英

Excel - calculate date time

I am trying to calculate the hour difference between two times. What I've been doing now only gives me hour indications like 1:30, 2:45, etc but I can't make diagrams based on these values. If I get 2:30 as the hour difference, it should become 2,5 . if the difference is 2:45 that should be 2,75 .

Change your formula to:

(B2-A1)*24

and format as General

You should just be able to subtract 1 datetime from the other. Try this:

  1. In cell A1, enter "09/17/2012 10:00" (Excel should automatically recognize this as a date)
  2. In cell A2, enter "09/17/2012 11:30"
  3. In cell A3, "=(A2-A1)*24" . The result is 1.5.

The problem may be that you are trying to subtract 1 'time' from another 'time' without a date component. In that case, Excel may not recognize your value as a 'time'. Try adding a dummy date to the beginning of the time.

One limitation of this is that you will get an error response of "########" if the 2nd date is earlier than the 1st (because the result is negative). If this is an issue, try "=ABS(A2-A1)*24" instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM