This tutorial focuses on various ways to calculate times in Excel. You will find a few useful formulas to add and subtract times, calculate time difference, or elapsed time, and more.
In the last week's article, we had a close look at the specificities of Excel time format and capabilities of basic time functions. Today, we are going to dive deeper into Excel time calculations and you will learn a few more formulas to efficiently manipulate times in your worksheets.
How to calculate time difference in Excel (elapsed time)
To begin with, let's see how you can quickly calculate elapsed time in Excel, i.e. find the difference between a beginning time and an ending time. And as is often the case, there is more than one formula to perform time calculations. Which one to choose depends on your dataset and exactly what result you are trying to achieve. So, let's run through all methods, one at a time.
Formula 1. Subtract one time from the other
As you probably know, times in Excel are usual decimal numbers formatted to look like times. And because they are numbers, you can add and subtract times just as any other numerical values.
The simplest and most obvious Excel formula to calculate time difference is this:
Depending on you data structure, the actual time difference formula may take various shapes, for example:
Formula | Explanation |
=A2-B2 |
Calculates the difference between the time values in cells A2 and B2. |
=TIMEVALUE("8:30 PM") - TIMEVALUE("6:40 AM") |
Calculates the difference between the specified times. |
=TIME(HOUR(A2), MINUTE(A2), SECOND(A2)) - TIME(HOUR(B2), MINUTE(B2), SECOND(B2)) |
Calculates the time difference between values in cells A2 and B2 ignoring the date difference, when the cells contain both the date and time values. |
Remembering that in the internal Excel system, times are represented by fractional parts of decimal numbers, you are likely to get the results similar to this:
The decimals in column D are perfectly true but not very meaningful. To make them more informative, you can apply custom time formatting with one of the following codes:
Time code | Explanation |
h | Elapsed hours, display as 4. |
h:mm | Elapsed hours and minutes, display as 4:10. |
h:mm:ss | Elapsed hours, minutes and seconds, display as 4:10:20. |
To apply the custom time format, click Ctrl + 1 to open the Format Cells dialog, select Custom from the Category list and type the time codes in the Type box. Please see Creating a custom time format in Excel for the detailed steps.
And now, let's see how our time difference formula and time codes work in real worksheets. With Start times residing in column A and End times in column B, you can copy the following formula in columns C though E:
=$B2-$A2
The elapsed time is displayed differently depending on the time format applied to the column:
Note. If the elapsed time is displayed as hash marks (#####), then either a cell with the formula is not wide enough to fit the time or the result of your time calculations is a negative value.
Formula 2. Calculating time difference with the TEXT function
Another simple technique to calculate the duration between two times in Excel is using the TEXT function:
- Calculate hours between two times:
=TEXT(B2-A2, "h")
- Return hours and minutes between 2 times:
=TEXT(B2-A2, "h:mm")
- Return hours, minutes and seconds between 2 times:
=TEXT(B2-A2, "h:mm:ss")
Notes:
- The value returned by the TEXT function is always text. Please notice the left alignment of text values in columns C:E in the screenshot above. In certain scenarios, this might be a significant limitation because you won't be able to use the returned "text times" in other calculations.
- If the result is a negative number, the TEXT formula returns the #VALUE! error.
Formula 3. Count hours, minutes or seconds between two times
To get the time difference in a single time unit (hours ,minutes or seconds), you can perform the following calculations.
Calculate hours between two times:
To present the difference between two times as a decimal number, use this formula:
Supposing that your start time is in A2 and end time in B2, you can use a simple equation B2-A2 to calculate the difference between two times, and then multiply it by 24, which is the number of hours in one day:
=(B2-A2) * 24
To get the number of complete hours, use the INT function to round the result down to the nearest integer:
=INT((B2-A2) * 24)
Total minutes between two times:
To calculate the minutes between two times, multiply the time difference by 1440, which is the number of minutes in one day (24 hours * 60 minutes = 1440).
As demonstrated in the following screenshot, the formula can return both positive and negative values, the latter occur when the end time is less than the start time, like in row 5:
=(B2-A2)*1440
Total seconds between times:
To get the total seconds between two times, you multiply the time difference by 86400, which is the number of seconds in one day (24 hours * 60 minutes * 60 seconds = 86400).
In our example, the formula is as follows:
=(B2-A2)* 86400
Note. For the results to display correctly, the General format should be applied to the cells with your time difference formula.
Formula 4. Calculate difference in one time unit ignoring others
To find the difference between 2 times in a certain time unit, ignoring the others, use one of the following functions.
- Difference in hours, ignoring minutes and seconds:
=HOUR(B2-A2)
- Difference in minutes, ignoring hours and seconds:
=MINUTE(B2-A2)
- Difference in seconds, ignoring hours and minutes:
=SECOND(B2-A2)
When using Excel's HOUR, MINUTE and SECOND functions, please remember that the result cannot exceed 24 for hours and 60 for minutes and seconds.
Note. If the end time is less than the start time (i.e. the result of the formula is a negative number), the #NUM! error is returned.
Formula 5. Calculate elapsed time from a start time to now
In order to calculate how much time has elapsed since the start time to now, you simply use the NOW function to return today's date and the current time, and then subtract the start date and time from it.
Supposing that the beginning date and time is in call A2, the formula below returns the following results, provided you've applied an appropriate time format to column B, h:mm in this example:
=NOW()-A2
In case the elapsed time exceeds 24 hours, use one of these time formats, for example d "days" h:mm:ss like in the following screenshot:
If your starting points contain only time values without dates, you need to use the TIME function to calculate the elapsed time correctly. For example, the following formula returns the time elapsed since the time value in cell A2 up to now:
=TIME(HOUR(NOW()), MINUTE(NOW()), SECOND(NOW())) - A2
Note. The elapsed time is not updated in real-time, it refreshes only when the workbook is reopened or recalculated. To force the formula to update, press either Shift + F9 to recalculate the active spreadsheet or hit F9 to recalculate all open workbooks.
Formula 5. Display time difference as "XX days, XX hours, XX minutes and XX seconds"
This is probably the most user-friendly formula to calculate time difference in Excel. You use the HOUR, MINUTE and SECOND functions to return corresponding time units and the INT function to compute the difference in days. And then, you concatenate all these functions in a single formula along with the text labels:
=INT(B2-A2) & " days, " & HOUR(B2-A2) & " hours, " & MINUTE(B2-A2) & " minutes and " & SECOND(B2-A2) & " seconds"
To instruct your Excel time difference formula to hide zero values, embed four IF functions into it:
=IF(INT(B2-A2)>0, INT(B2-A2) & " days, ","") & IF(HOUR(B2-A2)>0, HOUR(B2-A2) & " hours, ","") & IF(MINUTE(B2-A2)>0, MINUTE(B2-A2) & " minutes and ","") & IF(SECOND(B2-A2)>0, SECOND(B2-A2) & " seconds","")
The syntax may seem excessively complicated, but it works :)
Alternatively, you can calculate time difference by simply subtracting the start time from the end time (e.g. =B2-A2
), and then apply the following time format to the cell:
d "days," h "hours," m "minutes and" s "seconds"
An advantage of this approach is that your result would be a normal time value that you could use in other time calculations, while the result of the complex formula discussed above is a text value. A drawback is that the custom time format cannot distinguish between zero and non-zero values and ignore the latter. To display the result in other formats, please see How to show time over 24 hours, 60 minutes, 60 seconds.
How to calculate and display negative times in Excel
When calculating the time difference in Excel, you may sometimes get the result as ###### error because the difference is a negative time. But is there a way to show negative times properly in Excel? Of course, there is a way, and even more than one :)
Method 1. Change Excel Date System to 1904 date system
The fastest and easiest way to display negative time normally (with a minus sign) is switching to the 1904 date system. To do this, click File > Options > Advanced, scroll down to the When calculating this workbook section and put a tick in the Use 1904 date system box.
Click OK to save the new settings, and from now on negative times will be displayed correctly, like negative numbers:
Method 2. Calculate negative time in Excel with formulas
Is changing Excel's default Date System is not an option, then you can force negative times to display properly using one of the following formulas:
=IF(A2-B2>0, A2-B2, "-" & TEXT(ABS(A2-B2),"h:mm"))
=IF(A2-B2>0, A2-B2, TEXT(ABS(A2-B2),"-h:mm"))
Both formulas check if the time difference (A2-B2) is greater than 0, and if it is they return that difference. If the time difference is less than zero, the first formula calculates the absolute difference and concatenates the minus sign. The second formula yields exactly the same result by using a negative time format "-h::mm".
Note. Please keep in mind that unlike the first method that treats negative times as negative numeric values, the result of the TEXT function is always a text string that cannot be used in calculations or other formulas.
Adding and subtracting time in Excel
Basically, there are 2 ways to add and subtract time in Excel:
- Using the TIME function
- Using arithmetic calculations based on the number of hours (24), minutes (1440) and seconds (86400) in one day
The TIME(hour, minute, second)
function makes Excel time calculations really easy, however it does not allow adding or subtracting more than 23 hours, or 59 minutes, or 59 seconds. If you are working with bigger time intervals, then use one of the arithmetic calculations demonstrated below.
How to add or subtract hours to time in Excel
To add hours to a given time in Excel, you can use one the following formulas.
TIME function to add under 24 hours
For example, if your start time is in cell A2, and you want to add 2 hours to it, the formula is as follows:
=A2 + TIME(2, 0, 0)
Note. If you try adding more than 23 hours with the TIME function, the specified hours will be divided by 24 and the remainder will be added to the start time value. For example, if you try to add 25 hours to "6/2/2015 10:00 AM" (cell A4) using the formula =A4 + TIME(25, 0, 0)
, the result will be "06/02/2015 11:00", i.e. A4 + 1 hour.
Formula to add any number of hours (under or over 24 hours)
The following formula has no limitations to the number of hours you want to add:
For example, to add 28 hours to the start time in cell A2, enter the following formula:
=A2 + (28/24)
To subtract hours from a given time, you use analogous formulas, and just replace "+" with the minus sign:
For example, to subtract 3 hours from the time in cell A2, either of the following formulas will do:
=A2-(3/24)
=A2-TIME(3,0,0)
To subtract more than 23 hours, use the first one.
How to add / subtract minutes to time in Excel
To add minutes to a given time, employ the same techniques that we've just used for adding hours.
To add or subtract under 60 minutes
Use the TIME function and supply the minutes you want to add or subtract in the second argument:
And here are a couple of real-life formulas to calculate minutes in Excel:
To add 20 minutes to the time in A2: =A2 + TIME(0,20,0)
To subtract 30 minutes from the time in A2: =A2 - TIME(0,30,0)
To add or subtract over 60 minutes
In your calculation, divide the number of minutes by 1440, which is the number of minutes in a day, and add the quotient to the start time:
To subtract minutes from time, simply replace plus with the minus sign. For example:
To add 200 minutes: =A2 + (200/1440)
To subtract 300 minutes: =A2 -(300/1440)
How to add / subtract seconds to a given time
Second calculations in Excel are done in a similar fashion.
To add under 60 seconds to a given time, you can use the TIME function:
To add more than 59 seconds, use the following formula:
To subtract seconds, utilize the same formulas with the minus sign (-) instead of plus (+).
In your Excel worksheets, the formulas may look similar to these:
To add 30 seconds to A2: =A2 + TIME(0,0,31)
To add 1200 seconds to A2: =A2 + (1200/86400)
To subtract 40 seconds from A2: =A2 - TIME(0,0,40)
To subtract 900 seconds from A2: =A2 - (900/86400)
How to sum time in Excel
The Excel sum time formula is the usual SUM function, and applying the proper time format to the result is what does the trick.
Supposing you have a few project times in column B and you want to add them up. You write a simple SUM formula like the one below and get the result in the default format such as hh:mm:ss.
=SUM(B2:B4)
In some cases the default time format works just fine, but sometimes you may want more, for example to display the total time as minutes and seconds, or seconds only. The good news is that no other calculations are required, all you have to do is apply custom time format to the cell with the SUM formula.
Right click the cell and select Format Cells in the context menu, or press Ctrl + 1 to open the Format Cells dialog box. Select Custom from the Category list and type one of the following time formats in the Type box:
- To display total time as minutes and seconds: [m]:ss
- To display total time as seconds: [ss]
The result will look as follows:
In order to add up more than 24 hours, you use the same SUM formula as discussed above, and apply one of the following time formats to the cell: To see how these custom time formats may look like in your Excel worksheet, please have a look at the screenshot below, where the same SUM formula is entered in cells A9 to A13: Note. The above custom time formats work for positive values only. If the result of your time calculations is a negative number, e.g. when you are subtracting a bigger time from a smaller time, the result will be displayed as #####. To display negative times differently, please see custom format for negative time values.
Also, please keep in mind that the time format applied to a cell changes only the display presentation without changing the cell's value. For example, in the screenshot above, cell A13 looks like text, but in fact it's a usual time value, which is stored as a decimal in the internal Excel system. Meaning, you are free to refer to that cell in other formulas and calculations. For more information, please see How to calculate and show over 24 hours, 60 minutes, 60 seconds.How to sum over 24 hours in Excel
Format
Displays as
Explanation
[h]:mm
30:10
Hours and minutes
[h]:mm:ss
30:10:20
Hours, minutes and seconds
[h] "hours", mm "minutes", ss "seconds"
30 hours, 10 minutes, 20 seconds
d h:mm:ss
1 06:10:20
Days, hours, minutes and seconds
d "day" h:mm:ss
1 day 06:10:20
d "day," h "hours," m "minutes and" s "seconds"
1 day, 6 hours, 10 minutes and 20 seconds
=SUM($B$2:$B$4)
Date & Time Formula Wizard - quick way to calculate times in Excel
Now that you know a bunch of different formulas to add and subtract times in Excel, let me show you the tool that can do it all. Okay, almost all :)
Here comes Ablebit's Date & Time Formula Wizard for Excel:
In the Date & Time Wizard dialog window, you switch to the Add or Subtract tab, depending on which operation you want to perform, and do the following:
- Click the Show time fields link in the left part of the window.
- Supply values or cell references for the formula arguments. As you fill in the argument boxes, the wizard builds the formula in the selected cell.
- When finished, click the Insert Formula
That's it! For example, this is how you can add the specified number of hours, minutes and seconds to the time in A4:
If you need to copy the formula to other cells, fix all references except the cell containing the original time (A4) with the $ sign like shown in the screenshot below (by default, the wizard always uses relative references). Then double-click the fill handle to copy the formula down the column and you are good to go!
Besides time calculations, the wizard can also add and subtract dates, get the difference between two dates, and calculate age from the birthdate.
If you are curious to try this tool in your own worksheets, you are welcome to download the evaluation version of our Ultimate Suite below.
This is how you calculate time in Excel worksheets. To learn other ways to manipulate dates and times in Excel, I encourage you to check out the resources at the end of this article. I thank you for reading and hope to see you on our blog next week!
Available downloads
Excel Time Calculations - formula examples (.xlsx file)
Ultimate Suite - trial version (.exe file)
977 comments
hi!, I've managed to get the formula to successfully work with only 1 time in and 1 time out. how do i add more times to the formula. for example i want to calculate how long i was working for. i signed it at 8, signed out at 12:30 for lunch. signed back in at 1:30 and signed out at 5:15 at the end of the day. how do i make this a formula that calculates the number of hours and number of remaining minutes separately.
Hi!
I recommend reading this guide: How to convert time to decimal number, hours, minutes or seconds in Excel. I hope it’ll be helpful.
How do I update this formula from using an 8 hour shift to a 10 hour shift? ,TIME(E6+8-INT(E11),F6+30-(60*(E11-INT(E11))),0),TIME(E6+8-INT(E11),F6-(60*(E11-INT(E11))),0)))))
Hi!
I cannot guess what your formula is doing. But you can try changing the number 8 to 10. If that doesn't help, give more information about your problem.
How to subtract dd-mm-yy hh:mm am/pm valeues in excel (12hours format)
For example
2/17/22 12:00pm -2/17/22 2:00pm = 2 hours
How to get this in excel
Hello!
I recommend you read these tips.
I hope it’ll be helpful.
My question is stock movement date is
2022-02-14 16.51.12
Gate entry date is
2022-02-14 16.48.27
Please help me how to calculated this hours, min, second
Hello!
If your data is written in date and time format, calculate the difference between these cells and set the cell with the formula to the time format.
If your data is written as text, use these guidelines: How to convert text to date in Excel.
I hope it’ll be helpful. If something is still unclear, please feel free to ask.
Hi!
If the value "Mon - THU (Morning)" is recorded in one cell, then it is impossible to search through such data.
Anyone have formula to determine rate by weekday and weekend?
Mon - THU (Morning) - $10
Mon - THU (Night) - $11
FRI - SUN (Morning) - $12
FRI - SUN (Night) - $13
How to subtract 30 min if the shift is for 8hr 30 min .
Hello!
To extract minutes from time, use the MINUTE function.
If this is not what you wanted, please describe the problem in more detail.
How to determine a work shift, 06:30 to 18:59 - Morning, 19:00 to 06:29 - Night.
=IF([@[Clock In Time]]>=TIME(6,30,0),IF([@[Clock In Time]]<=TIME(18,59,0),"Morning","Night"))
Had try this formula but when key the clock in time between 01:00 - 06:29, it will come out "FALSE"
please help....
Hello!
Please try the following formula:
=IF(AND([@[Clock In Time]]>=TIME(6,30,0),[@[Clock In Time]]<=TIME(18,59,0)),"Morning","Night"))
I can't check the formula that contains unique references to your workbook worksheets, sorry.
it doesn't work :(
Hi!
Maybe your links were wrong.
=IF(AND(A2>=TIME(6,30,0),A2<=TIME(18,59,0)),"Morning","Night")
Hello sir ,
I have one task to solve . In our company there is 3 working shifts are there,
1. 06:30 to 15:30 shift A
2. 15:30 to 23:30 shift B
3. 00:30 to 06:30 shift C
and i want to add one column which give me only shift name when the employee place there entry in any time
for example if
if employee enter after 06:30 but before 15:30 then formula should give value "A"
if employee enter after 15:30 but before 23:30 then formula should give value "B"
if employee enter after 00:30 but before 06:30 then formula should give value "C"
Please guide sir , what will be the best formula ?
Hello!
If I got you right, the formula below will help you with your task:
=CHOOSE(IFERROR(MATCH(1,($A$1:$A$3D1),0),3),"A","B","C")
Column A - the beginning of the shift, Column B - the end of the shift. D1 is the time entered by the employee. Determine the desired interval number using the MATCH function. The CHOOSE function will replace the interval number with the desired letter.
In excel, How to subtract 4:58:00 Hrs from 02/07/2022 04:27:00 ?
Hello!
If your value is written in date and time format, then you can extract the time in the way described in this example
=A1-INT(A1)
Set time format in this cell.
But you can't get the time 4:58:00 from your value. Only 04:27:00.
Per hour 800 rupees then what is the cost for 4 Hrs 20Min
Hello!!! Can I ask what formula should I use if the driver is arriving to job and he is paid for waiting time 30.08€ per after 45 minutes. I need first to find how many minutes and then how much they will get paid. Thank you very much indeed.
Hi!
The number of minutes divided by 45 and multiplied by 30.08
How to convert 2 days 19:30:18.530787 into total hours and minutes.
Hello!
To convert text to date and time, use the formula
=LEFT(A2,SEARCH(" ",A2)-1)+TIMEVALUE(MID(A2,SEARCH(" ",A2,6)+1,8))
Then set a custom time format [h]:mm to show times over 24 hours as described in this tutorial.
Hi I'm trying to calculate -minus break times, without the break time being displayed. So for example
if total hours is greater than 4:30-0:15=04:15
if total hours is greater than 6:00-0:20=05:40
If total hours is greater than 8:00-0:30=07:30
But all in the same Formula if that makes sense. Is this possible?
Hello!
If I understand your task correctly, use formula with nested IF function:
=IF(A2 > =TIME(8,0,0),A2-TIME(0,30,0),IF(A2 > =TIME(6,0,0),A2-TIME(0,20,0),IF(A2 > =TIME(4,30,0),A2-TIME(0,15,0),A2)))
I'm calculating time difference with dates using the formula:
=TIME(HOUR(A2), MINUTE(A2), SECOND(A2)) - TIME(HOUR(B2), MINUTE(B2), SECOND(B2))
The issue occurs when attempting to calculate the time elapsed in H:MM:SS for when it rolls into the next day, ie 12/01/2021 19:37 to 12/02/2021 03:40 .
Is there a better formula to use when for the example above or a way to convert the data of the 12/02/2021 03:40 and use the same formula?
Thank you
Hi!
This issue has already been discussed many times in our blog. For example, read this comment.
How to convert 13451 into Hours and minutes?
Hi!
You have not explained what your number means. I guess it's minutes. I recommend checking out this guide:
How to convert numbers to time format
To convert minutes to time format, divide by 60 and 24. Set the time format you need in the cell.
=A1/60/24
Hi, I am looking for what I believe is a simple solution, but, I think that I am just not "asking" google the right question LOL
Anyways, I have my time total figured out.
3:20 pm - 3:20 am - 12hours.
Now, I would like to take that 12 hours (say it is in cell u7) and have it show 8 hours in d7 (regular time), anything over 8 hours (up to 3 hours) to show in e7 (overtime). Then, anything over that 3 hours, to show in i7 (double time).
Thank you.
Hello!
If I understand your task correctly, the following formulas should work for you:
=IF(U7>TIME(8,0,0),TIME(8,0,0),U7)
=IF(U7>D7,IF(U7-D7>TIME(3,0,0),TIME(3,0,0),U7-D7),"")
Hope this is what you need.
I want remove 01/01/1900 12:52:52 AM
Please guide
Hi there! Thank you so much for this post!
I have a question. I've set up a sheet with the formula shown here =TEXT(D2-C2, "h:mm") where I calculate the amount of minutes/hours worked on specific tasks. I then wanted to add all of these together, but not sure how to go about it, as =SUM() of all of those =TEXT() doesn't work at all...
Could you point me in the right direction please?
Thank you!
Hi!
Subtract the original time data with something like this:
=SUM(D2:D9-C2:C9)
I hope it’ll be helpful.
It really works. Thank you very much
Hi,
How do you create a formula to add a time from a specific hour onwards. For example start time should be 7PM. data is 6:21PM, formula should start counting at 7PM onwards.
Hi!
The information you provided is not enough to understand your case and give you any advice, sorry. How much time do you want to add and what result do you want to get?
I am trying to use a simple formula that will auto sum total hours worked. Everything works fine as long as the cells that are being added include an increment of at least one hour. However, all of the fields that have an amount between :01 and :59 are being 'skipped over' in the formula. Please see my example below:
Day 1 Day 2 Day 3 Day 4 Day 5 Total Hours Worked
1:00 1:00 1:00 1:00 :05 4:00
As you can see, Day 5 was not included in the sum of the cell 'Total Hours Worked', and I can't see to figure out how to manipulate excel to include it.
Hello!
Only numerical values can be added.
:05 is text, not a number. Write down the time in the correct format and you will be fine.
Hi Team,
My start time is - 12:12:00 AM 23-Nov-21
My End time is - 10:46:00 PM 22-Nov-21
Query : how do i subtract this ( Start time - end time)?
Hi!
Please re-read the article above. It is impossible to find the difference. The start time must be less than the End time.
Hi , I need to substract the time log in time, log out time, lunch hours & if their is any kind other break downs for the machine. so i need total working hours.
Hello,
I am not sure what formula I have to use to create 3 cells. One which shows date and time now. 2nd is where I would enter employees time worked (for example 32 hours). 3rd cell would have to show the next date and time period the person goes on call.
Example: today is 10/8/2021 13:00. Employee has called and I see they worked 29 hours and 35 mins. I would need the 3rd cell to tell me the date and time that's going to be when I add 29:35.
Thanks in advance!
Hi!
In the third cell, just find the sum of the first two. Read about how to add time in different ways in the article above.
How do I get excel to choose from four cells, the one with the time in it, and then find the difference between it and a finish time
Hi!
Time in Excel is written as a number. If you tell me what is written in the other three cells and how these three cells differ from the fourth, I will try to help you. Give an example.
Hi. I am preparing attendance sheet in excel but daily basis I am adding labor intime (as one day present) and want total attendance days in the total of each employee.
Please guide how to do so?
Hello!
To calculate the sum of days for each employee, I recommend using the SUMIFS function.
I am wondering how to calculate the time of 23:09:54 of 7/9/2021 to 0:32:32 of 8/9/2021. How do I calculate the time difference/ time worked? What do I write in the excel sheet ? Do i need to add the dates ? Does it only work for 12- hour clock? What formula should I use?
Hi!
If your data is recorded as date and time, use subtraction. If the time is recorded separately and if the end time is longer than the start time, then you need to add 1 day to their difference
=IF(A1 > A2,A2-A1+1,A2-A1)
Hi, i have 10 employees who rotate day and night shift, i want to setup a formula that i dont have to manually calculate their times clocked in all the different areas - example:
EmployeeA clocks in on night shift at 18h00 at the main gate then clocks at 19h30 in at the offices, again clocks in at Lamproom at 20h00 he clocks out at Lamproom at 23h00 at office 24h45 and out at main gate at 02h00am (next morning). i need to calculate what his total shift was ie. 8hrs, shift underground (lamproom in and out), the differences between main gate and office 1h30 and office to lamproom - is there a way i can do this on excel? i tried Pivot but the pivot doesnt calculate the time worked it only sums/counts
Hello!
If the end time is longer than the start time, then you need to add 1 day to their difference
=IF(A1 > A2,A2-A1+1,A2-A1)
Calculate the amount of time differences.
=IF(A1 > A2,A2-A1+1,A2-A1)+IF(A3 > A4,A4-A3+1,A4-A3)+IF(A5 > A6,A6-A5+1,A6-A5)
Hi thank you for sharing this, I have a problem with my formula with hours that formulated using =MOD and the formate number is [h:mm]. Now the problem was whenever I multiplied the hours into $ pay rate, it is showing a wrong result. :(
Hi!
What formula are you using? Explain with your data.
Hi,
1)I have applied a mid function as =MID(H2,11,8) which is 08:11:08 and also add 4 hrs which is TIME(4,0,0).
But when I add the time the result becomes 12:12PM Because I am applying on the above formula.
How I ll get the result as 12:12:18 without showing AM/PM?
2) how can I convert 08.11.08 to 08:11:08?
Please help.
Hello!
Here is the article that may be helpful to you: How to change Excel date format and create custom formatting
The MID function is used to work with text, not dates.
Ok, I ll try with text.
What will be the formula for 2nd one? Please help
Hi!
To replace characters in text, use the SUBSTITUTE function:
=SUBSTITUTE(A1,".",":")
Is there a way to make the end result a decimal number? Here is what I am trying to do:
Time In Time Out Total Hours
8:30 AM 4:00 PM 7.5
When I follow the formula in the example above I just get 7 for the total hours.
Thank you.
Hi!
There are many formulas in this article. Which one are you using?
Formula 2. Calculating time difference with the TEXT function
I want to calculate the median and mean. Say I have column of 500k rows, which have the time difference between 2 timestamps written as "0 days, 0 hours, 27 minutes and 53 seconds". How do I calculate the median and mean of these?
Hi!
Your timestamp is recorded as text. Therefore, no mathematical operations with it are possible.
Is there a way to calculate the differences in time values between two columns easily?
As an example if I am trying to calculate quickly the difference in time values between:
column A : 16hrs30min (16.30) value
column B: 16hours40min (16.40) value
Column C (shows difference): -0.10min
I cannot seem to find a formula that will do this. I need to show a positive difference or a negative difference (e.g. -0.10, +0.10, +1.30,etc)
Do you know a formula I can use?
Thank you
Hello,
I need to substract the breaks from the gross working hours. I can't find the right formula.
Example : if working hours 3.5 to below 6 hours (3.5 hours to 5.9 hours) substract 30 min break time, if hours 6 to overs, substract 60 minutes.
Could you please hepl me for solve this?
Thank you
Hi!
See the answer in this comment.
Hi! Sorry to bother you. For your info, I've tried this formula many times, but it's not working with my time. If you could please do my formula again with my time, I will be grateful to you.
Thank you.
Hello,
How to create formula that calculate time in a single cell? For example Cell A1 (4:30pm - 7:30pm) Cell A2 ( 3 hours). Please advice.
Thanks
Hello!
Please check the formula below, it should work for you:
=(MID(A1,SEARCH("–",A1,1)+2,LEN(A1)-SEARCH("–",A1,1)-3)&" "&RIGHT(A1,2))-(LEFT(A1,SEARCH("–",A1,1)-4)&" "&MID(A1,SEARCH("–",A1,1)-3,2))
dear alex,
thanks for the formula, but i still couldn't get it. possible to assist me in more detail for the formula above?
Thanks.
with the formula you given, the answer i get at cell A2 was 0.13 instead of 3.
Hi!
Use the General format in a cell with a formula to see all digits in a number. Use the time format to see 03:00:00 instead of 0.125
Hello,
I need to substract the breaks from the gross working hours. I just can't find the right formula even after reading so many comments.
The conditions are: if working hours >=9 substract 30 min break time, if hours are between 9 and 10, substract 45 min break time, if hours over 10, substract 60 minutes.
Could you please give me advice for this?
Thank you
Hello!
The formula below will do the trick for you
=IF(HOUR(A1)>=10,A1-60/1440,IF(HOUR(A1)>=9,A1-45/1440, A1-30/1440))
01-Jul-21 22:00 02-Jul-21 06:00
how we can get working hours in this condition
I am a swim coach and am trying to do an excel sheet where I take a swimmer's best time when they arrive and find the difference when they are done (did they drop time). I have an excel sheet pretty much done and it works well when the time is within the same minute (1:57.56 to 1:55.46 = -:2.10) I use #":"##"."00 as my cell formula. The issue come when I have a time in 2 different minutes (2:01.91 to 1:57.41) this should equal -:4.50 but I get -:44.50. Do you have guidance for me? Thank you in advance
Hello!
I used the format mm:ss.00 and got the result 00:04.50
I could not use your format.
Thank you. My formula lets me put in the times without having to type the punctuations and it lets the time read correctly no matter if it is 10 minutes or 30 seconds. If you do that (type just numbers) you should get the formula to work.
mm:ss.00 does get the correct number but it does not show a negative (I've played with how but can not make it happen) and it does not format well at least not aesthetically.
Any other advice?
Hi!
You will not be able to subtract minutes, since there are 60 seconds in 1 minute. In your case, 1 minute is 100 seconds.
I have an issue with a simple greater than calculation involving time (24hr) and can't seem to find a solution to show that:
=IF(F1>J1,0,100)
"23:00" is NOT greater than "0:00" but excel decides this is false.
How could I determine this when the time rolls over?
Hello!
Why do you think 23:00 is no more than 0:00? What result do you want to get? Please describe your problem in more detail.
Hi Alex,
The problem is to figure out If a shipment was sent late, or on time, and then sum up the late ones...
So with a simple formula, you can see results are not desirable when that midnight time rolls over.
IF SUM(A1-B1) >0, Then Count it
LEFT DUE DIFF
18:30 20:00 -1:30
20:45 23:00 -2:15
19:50 21:00 -1:10
20:45 22:00 -1:15
22:10 0:00 22:10 <----Not really late
23:48 1:00 22:48 <----Not really late
22:40 23:30 -0:50
Moving forward, we can add the date and that makes it accurate, but the issue is that I've got old entries to tally up and changing the time field to a date just makes it "1/1/1904" for every day.
Hope that describes it better?
Hi!
Time 00:00 is less than 23:00 since 00:00 is the beginning of the next day. You can calculate the time difference correctly only within a day. If the start and end times are different days, then you need to use the date and time.
You have not explained how to determine if the package was sent at the wrong time.
Thank you for this, it was a true help. :)
Hello
I am trying the method of B2-A2 (Updated date/time - Created date/time) and then formatting the results cell with d "days," h "hours," m "minutes and" s "seconds" and all seems well until I get to a certain value and then it is not displaying results correctly. I worked around this by using =INT(B2-A2) & " days, " & HOUR(B2-A2) & " hours, " & MINUTE(B2-A2) & " minutes and " & SECOND(B2-A2) & " seconds" but now I'm trying to average the results of the original B2-A2 values and am getting a value of 61.26262 which when formatting the cell with d "days," h "hours," m "minutes and" s "seconds" I should get 61 days... but am getting 1 days, 6 hours, 18 minutes and 10 seconds. How can I format the cell values to return the correct 61 days? Is it as simple as changing the formatted value of 1 days, 6 hours, 18 minutes and 10 seconds to 61 days, 6 hours, 18 minutes and 10 seconds?
Hello!
Please check out this article to learn how to get date difference in days, months and years.
Hope you’ll find this information helpful.
Hello sir ,
this formula is too good. And I want that same formula in Power BI . Can you please tell me what would be the formula for same purpose in Power BI ?
Hi
When I'm trying to sum the total time in HH:mm
Getting the total wrong I have applied the formula =sum(b2:b5) but still getting the wrong total
Hello!
You have not described your problem, but I hope this article will be useful to you: How to sum time in Excel
I hope my advice will help you solve your task.
Hello,
what if i need to calculate daily working hours (8) hrs if exceed 8 hrs to calculat the over time for the three shifts and the timing concidering timing from 19:00 to 07:00 as 1.5 rate and other hours will be in 1.25 rate
means
Example
Exmp1-08:00 to 20:00 8 hrs duty 4 hrs Over time ( 3hrs @1.25 & 1hr @1.5)
Exmp2-20:00 to 05:00 8 hrs duty 1 hr Over time (@1.5) (till 07:00 the rate will be 1.5)after 07:00 rate will be 1.25
Please advise
Looking to calculate the time difference excluding weekends and business hours for the time a user submits a support request. Weekends are sat/sun and business hours are 8-5.
Example time of the support request:
Submitted at 7:00am on Friday 5/7/21.
Request completed at 10:30am on Monday 5/10/21.
The answer when calculated manually would be 10.5 hours to complete the request.
What would the formula be for this?
Sorry, 11.5.
Hello!
If I understand your task correctly, the following formula should work for you:
=IF(NETWORKDAYS.INTL(A2,B2,1)=1,MIN(TIME(HOUR(B2),MINUTE(B2),0),TIME($C$1,0,0))-MAX(TIME(HOUR(A2),MINUTE(A2),0),TIME($B$1,0,0)),(NETWORKDAYS.INTL(A2,B2,1)-1)*($C$1-$B$1)+MAX(0,MIN(TIME(HOUR(B2),MINUTE(B2),0),TIME($C$1,0,0))-TIME(8,0,0))+TIME(18,0,0)-MAX(TIME(HOUR(A2),MINUTE(A2),0),TIME($B$1,0,0)))-IF(TIME(8,0,0)-(A2-INT(A2))>0,TIME(8,0,0)-(A2-INT(A2)),0)
A2 - start time
B2 - end time
B1 -start workday (8)
C1 - end workday (17)
The answer calculated 9+2.5=11.5 hours
I hope I answered your question. If something is still unclear, please feel free to ask.
What if not considering Start workday and end workday and instead just considering 8 hrs a day
Hi!
You can calculate the number of working days using the NETWORKDAYS.INTL function and multiply that result by 8.
Hi Alex,
You formula helps a lot for me. thank you so much for that. pls guide me to exclude weekends (Saturday & Sunday) from the below formula.
=INT(N374-H374) & " days, "&HOUR(N374-H374) & " hrs, " & MINUTE(N374-H374) & " mns"
Output is 20 days, 2 hrs, 44 mns.
Hi!
Count the number of holidays with the NETWORKDAYS.INTL function
=(INT(N374-H374)-NETWORKDAYS.INTL(H374,N374,"1111100")) & " days, "&HOUR(N374-H374) & " hrs, " & MINUTE(N374-H374) & " mns"
This should solve your task.
Alex,
This is brilliant. It's working. Thank you so much :-)
How to calculate difference of below time stamp
Respone Time (Before Entry) Respone Time (After Entry)
2021-04-20-17.05.26.661101 2021-04-20-17.05.27.149143
2021-04-20-17.05.56.336787 2021-04-20-17.05.56.507989
2021-04-20-17.05.57.052277 2021-04-20-17.05.57.129936
2021-04-20-17.06.58.825463 2021-04-20-17.06.58.913969
Hi,
Reread the article above. It describes in detail how to calculate the time difference.
To convert your text to date and time, I recommend reading the manual "How to convert text to date and number to date in Excel" and this commentary to it.
This should solve your task.
I have a question here. How to get the hour after minus from 73:50 - 70:91?
my results show #value
Hope to hear from you soon.
Thanks.
Hello!
Time cannot be written as 70:91. There cannot be more than 60 minutes in an hour. If instead of 70:91 you write 71:31, then you will succeed.
Thank you for the 'time in 1904 format' tip.
In a Mac it's under Excel preferences, Calculation then tick 'use 1904 date system'
Hello,
how to write coming late formula for 3 shifts (24 H).
1- 00:00 AM to 08:00 AM
2- 08:00 AM to 04:00 PM
3- 04:00 PM to 00:00 AM
In normal excel sheet I am try to calculate manpower efficiency which need time starts and time end. What is the formula for time starts if the person starts work by pressing "Y" in beside column. I tried with now() formula but it's keep on changing. I need once the activity start time should not be changed when the activity is closed and centering the closing time. I need in if programme
Hello!
To prevent your date from automatically changing, you can use several methods. Read this comment.
Hi Svetlana, you are obviously very skilled at using Excel. Your page on Excel time calculations came up in a search. I am hoping you can assist me in resolving a couple of issues within an existing Excel sheet i have made for home video logs of old videotapes.
I have many home videos of my kids growing up and I am entering the date, location, person, place, etc. information of each video into an Excel sheet.
I tried to copy and paste a sample of the heading of my sheet but the website would not allow me to do so. Let me know if there is a way to send you the sheet. If not here are the column headings:
DVD # Tape# Source Type Date of Event Time Start Time End Length (HR:MN:SC) Subject Names Event Name Location Notes
If you already have a sheet for my needs that would be great!
I would like your expertise on two matters. The first involves time calculations.
I found where I can format cells for Time/37:30:55 to help me calculate the time durations by entering the data in the Time Start and Time End columns to determine the duration in the Length column (this is calculated across a row. I also entered a formula to calculate the total duration in the Length column (going down) to determine the total length of the entire video tape or the total of all of the events.
Since the rows could be multiple because of the number of persons and descriptions of one event, I have to enter these formulas manually. Is there a way to put a formula into the Length (duration) column so when I enter the date in Time Start and Time End it will automatically subtract the Start from the End. For instance, one Length could be cell G3 and G5 and may skip to G9. Of course the end point to total the event durations in the Length column for the entire videotape would vary also since I do not know what row will be the last one.
The second request is hopefully more simple. I want to make sure that I am able to filter the logs if want to find all of the video clips in one video tape say of John or Disneyland or birthday. For instance in a cell naming characters within one event or row as I described above should I put a space or comma or colon between each word I want to search later? Before I start all of this data entry I want to make sure i have it formatted correctly. This will be important if I combine all of the individual video logs into one massive excel sheet to possible search for all of John's birthdays through the years to do a highlight movie.
Sorry for the lengthy request but I am a novice to Excel and making requests on forums.
Thank you in advance for your assistance and I look forward to your response.
Tony
Thank you very much
Very nice
Hi,
I have a problem working with the excel formula to calculate the End Date & Time from Start Date & Time for given Duration.
Its a 24/7 work but there is a chance for festival and natural disaster holidays so will maintain the holiday list separately. We have 2 shifts a day. each shift has below details
--------------------------------------------------------------------------------------------------------------------------------------------------------
Example :1 ( Day Shift )
----------------------------------
Start Time Stamp || Project Hours || Daily Shift Start || Break1 Start || Break1 End ||
1/7/2021 11:45 AM 12 10:00 AM 11:15 AM 11:30 AM
Lunch Start || Lunch End || Break2 Start || Break2 End || Daily Shift End || Dead Line
1:00 PM 1:30 PM 3:00 PM 3:15 PM 6:00 PM ????
--------------------------------------------------------------------------------------------------------------------------------------------------------
Example :2 (Night Shift)
----------------------------------
Start Time Stamp || Project Hours || Daily Shift Start || Break1 Start || Break1 End ||
1/7/2021 11:45 AM 28 6:30 PM 8:15 PM 8:30 PM
Lunch Start || Lunch End || Break2 Start || Break2 End || Daily Shift End || Dead Line
9:30 PM 10:00 PM 1:30 AM 1:15 AM 2:30 AM ????
--------------------------------------------------------------------------------------------------------------------------------------------------------
Conditions
=======================
Dead Line with Date & Time
Excludes the Holidays List
Calculate only the working hours
Exclude the Break & Lunch hours