# To get Hours or Minute between Two Time

In this article, you are going to learn time difference i.e. how to add or subtract between two times and to get negative time to remove ## in a cell. You can also extract hours, minutes and seconds from the given time.

Query: We have three columns Name, Start_time and End_time. Our task is to know how much time each user work including minutes and seconds. So basically find the difference of two times.

Formula to implement:

=IF(D5>C5, D5-C5, D5+C5)

Functions applicable:

The Excel IF function is a handy logical operator that returns a value based on a valid test of criteria, if it matches (TRUE) and another value if it does not.

Syntax

= IF(logical_test, value_if_true, [value_if_false])

Parameters

logical_test – The criteria to evaluate.
value_if_true [optional] – The value to return if criteria match (TRUE).
value_if_false – [optional] – The value to return if criteria does not match (FALSE).

Formula explanation:

=IF(D5>C5, D5-C5, D5+C5)

Result: 6:00:40

If the end time greater than start time then it will return hours, minutes and seconds after subtracting other than it will add two times together in a cell.

The same way you can get the same time by applying another formula with TEXT adding custom format.

Formula to implement:

=TEXT(D5-C5,”h:mm:ss”)

Result: 6:00:40

So, by this, you can get time difference with the use of any of the both to know the exact time taken by the user after knowing start and end time.

## Time difference without colon (“:”)

You may have time without colon (“:”) to properly format we can use Excel function to substitute part of a text string. And then find the difference between both times. Excel returns numbers series i.e. time value, not in minute. So to find value in minute we can simply add custom format as [m], the easy way. We can add other formats as well to find different values between time with Hour, Minute or Seconds.

Now Excel return minutes rather than numbers. We can also use  TEXT function for converting a value to a specific format.

## Negative Time Error

When you get result of time in the negative form it returns (##) in the cell to remove such time value i.e. to show negative time in Excel.

Manage Errors with formula below.

=TEXT(MAX(C3:D3)-MIN(C3:D3),”-h:mm:ss”)

Function applicable

Text: The Excel TEXT function allows converting a value to a specific format based on the given format codes. The function is useful to display text after inserting a given number formatting.

Max: The Excel MAX function returns the numerical with the highest value as per given reference of cell range.

Min: The Excel MIN function returns the smallest numerical with the lowest value as per given reference of cell range.

Formula explanation step by step:

Let’s break the formula into multiple small steps to understand its application.

First formula: Syntax: =MAX (number1, [number2], …)

=MIN (number1, [number2], …)

Step1: Result: 0.125

It will first show time then subtract large time with small time from the given time.

Second formula: Syntax: =TEXT (value, format_text)

Step 2: Result: -3:00:00

It will return negative time as bigger time with smaller after subtracting in “h:mm:ss” format.

Remember: You can also convert the format of time like 24 to 12 hours and so on.
{"ft_lang_label":"__label__en","ft_lang_prob":0.81276083,"math_prob":0.9665304,"size":3147,"snap":"2020-45-2020-50","text_gpt3_token_len":707,"char_repetition_ratio":0.12981229,"word_repetition_ratio":0.037593983,"special_character_ratio":0.23133142,"punctuation_ratio":0.13535032,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99390763,"pos_list":[0,1,2,3,4,5,6,7,8],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-12-05T22:42:10Z\",\"WARC-Record-ID\":\"<urn:uuid:2db33258-f422-4ea3-9dd5-a257c5d3a671>\",\"Content-Length\":\"117623\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:494f0492-ce86-415a-821b-8b4588fb9e2d>\",\"WARC-Concurrent-To\":\"<urn:uuid:e17a57d9-7c1d-4ee6-9bab-e9d8e9593388>\",\"WARC-IP-Address\":\"172.67.200.252\",\"WARC-Target-URI\":\"https://excelnumber.com/to-get-hours-between-two-time/\",\"WARC-Payload-Digest\":\"sha1:Z4ZIRNJV5EQKWZMCQJ2DHE32C6CDVKJC\",\"WARC-Block-Digest\":\"sha1:7ZR5UDKN2SY5EFPGLVKUUFJ65CMUNYVR\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-50/CC-MAIN-2020-50_segments_1606141750841.83_warc_CC-MAIN-20201205211729-20201206001729-00001.warc.gz\"}"}