Excel: auto format time of day when inputting time - excel

I'm inputting time in and time out logs for my business to calculate the total hours worked by individual contractor companies visiting my site. We operate from 6:30am to 5pm. Excel automatically formats the data as AM, except for 12:00-12:59 which it correctly assumes is PM. I need excel to recognize that any time between 12:00 and 5:00 is PM. This will save me from having to type PM for each "time out" which over the course of a year will save me hours.
I'm not really sure how to do this. I'm guessing an if/then macro?

You can change the cell format as shown below:
when you type 17:00 is correctly displayed as 5:00 PM

I just use military time to get around this problem. 5 PM is not 5:00, but rather 17:00. Then you don't need to put in a PM or anything. Note: This is just for inputting the time. You can still display the time as 5:00 PM or whatever by formatting those cells or columns as the 'Time' type.
1 PM = 13:00
2 PM = 14:00
3 PM = 15:00
4 PM = 16:00
5 PM = 17:00
6 PM = 18:00
etc.

Related

How to create a statement to count total of date and time

I have data in two separate columns like this
But how can I count how many rows are occurring within say a window of 6 AM to 10 PM and outside a window of 10:01 PM to 5:59 AM?
The first column cells are formatted as General. The second column cells are custom h:mm:ss
Fuller View
Here I have a formula to count how many times "Mon" comes up in the left column
=COUNTIF($D:$D,"*"&$K5&"*")
And this is what I have when I try to combine the two to determine how many "Mon" entries were between 06:00 AM and 10:30 PM
=COUNTIFS($D:$D,"*"&$K5&"*",$E:$E,SUMPRODUCT((E2:E119>=M4)*(E2:E119<N4)))
but I get a fat 'ol zero
Yet if I run
=SUMPRODUCT((E2:E119>=M4)*(E2:E119<N4))
I get 116 as a return for the amount of times that a cell is between 06:00 AM and 10:30 PM
So BLUF - I want to count how many times a row has "Mon" and a corresponding time between 06:00 AM and 10:30 PM then I can replicate it for the rest of the days of the week.
New update-dtd 10/11/2022
Right now I know that there are 4 instances where Tuesday had after-hours calls:
Instance one was at 5:59 AM on the 11th
Instance two was at 5:57 AM on the 11th
Instance three was at 10:39 PM on the 11th
& Instance four was at 10:36 PM on the 11th
but with the formula of =COUNTIFS($D:$D,""&$K7&"",$E:$E,">="&$O$5,$E:$E,">"&$P$5)
I am only accounting for 2 of those instances - the 10:39 PM and the 10:36 PM instance (found this out by testing/removing the values in the cells to see what changed the total).
How would I capture the times that are between midnight and 05:59 AM, to include 5:59 AM?
#ScottCraner solved this with
=COUNTIFS($D:$D,""&$K5&"",$E:$E,">="&M4,$E:$E,"<"&N4)

Time elapsed between two dates (in "working hours")

I must calculate in Excel the time that a Tech Support takes to resolve a problem, in his working hours.
Example :
Ticket created at : 04:00 PM the Friday 3 June 2022
Ticket resolved at : 10:00 AM the Monday 6 June 2022
Working hours : 09:00 AM to 12:00, and 01:30 PM to 06:00 PM
So the result will be : He took 3 hours to resolve the problem.
I'm open to any formula, even in VBA :)
Thanks.
EDIT 1 :
I'm using this formula currently :
=IF((NETWORKDAYS(D2;E2;PublicHolidays)-1)*(Working_Hours!$B$3-Working_Hours!$B$2)
+IF(NETWORKDAYS(D2;E2;PublicHolidays);MEDIAN(MOD(E2;1);Working_Hours!$B$3;Working_Hours!$B$2);Working_Hours!$B$3)
-MEDIAN(NETWORKDAYS(D2;E2;PublicHolidays)*MOD(D2;1);Working_Hours!$B$3;Working_Hours!$B$2)
+(NETWORKDAYS(D2;E2;PublicHolidays)-1)*(Working_Hours!$E$3-Working_Hours!$E$2)
+IF(NETWORKDAYS(D2;E2;PublicHolidays);MEDIAN(MOD(E2;1);Working_Hours!$E$3;Working_Hours!$E$2);Working_Hours!$E$3)
-MEDIAN(NETWORKDAYS(D2;E2;PublicHolidays)*MOD(D2;1);Working_Hours!$E$3;Working_Hours!$E$2)<0;0;(NETWORKDAYS(D2;E2;PublicHolidays)-1)*(Working_Hours!$B$3-Working_Hours!$B$2)
+IF(NETWORKDAYS(D2;E2;PublicHolidays);MEDIAN(MOD(E2;1);Working_Hours!$B$3;Working_Hours!$B$2);Working_Hours!$B$3)
-MEDIAN(NETWORKDAYS(D2;E2;PublicHolidays)*MOD(D2;1);Working_Hours!$B$3;Working_Hours!$B$2)
+(NETWORKDAYS(D2;E2;PublicHolidays)-1)*(Working_Hours!$E$3-Working_Hours!$E$2)
+IF(NETWORKDAYS(D2;E2;PublicHolidays);MEDIAN(MOD(E2;1);Working_Hours!$E$3;Working_Hours!$E$2);Working_Hours!$E$3)
-MEDIAN(NETWORKDAYS(D2;E2;PublicHolidays)*MOD(D2;1);Working_Hours!$E$3;Working_Hours!$E$2))
Well, this is a start, but you need to think about how to deal with multiple days etc:
All the example times shown are formatted as dd.mm.yy hh:mm, even consider putting the Day start & end as just the hour.

How to Calculate difference between hours when the cells contain date in date format? And there are some conditions too

Need difference between Created & Closed In Hours along with below
The TAT hour to be calculated between 9:00 am to 09:00 pm which is working hours, if created time us 09 pm then it should be considered from next day 9 am.
Sunday is Holiday
I have tried:- =Created-Closed Date, but don't know how to exclude Sunday and calculate only shift hours.
Yes! Finally Self Got Answer For it.
Here is that
=(NETWORKDAYS(A2,B2)-1)*("21:00:00"-"09:00:00")
+IF(NETWORKDAYS(B2,B2),MEDIAN(MOD(B2,1),"21:00:00","09:00:00"),"21:00:00")
-MEDIAN(NETWORKDAYS(A2,A2)*MOD(A2,1),"21:00:00","09:00:00")

How do I format cells to display a time range instead of just the time?

I'm trying to create a schedule for myself, but I get confused by seeing the following:
8:00 AM
8:30 AM
9:00 AM
9:30 AM
10:00 AM
10:30 AM
11:00 AM
11:30 AM
12:00 PM
I can never remember whether I am looking at the right block, so I instead want to see this:
8:00 AM to 8:30 AM
8:30 AM to 9:00 AM
9:00 AM to 9:30 AM
9:30 AM to 10:00 AM
Is there an easy way to do this that doesn't involve me typing it into every cell? I want to be able to flash fill the rest of my table, if I can.
(Note: the below is a workaround where I just made a separate column, but it'd be nice if I could do it in one cell.)
Start End
8:00 AM 8:30 AM
8:30 AM 9:00 AM
9:00 AM 9:30 AM
9:30 AM 10:00 AM
10:00 AM 10:30 AM
10:30 AM 11:00 AM
11:00 AM 11:30 AM
11:30 AM 12:00 PM
12:00 PM 12:30 PM
Use this formula:
=TEXT((ROW(1:1)-1)*TIME(0,30,0)+TIME(8,0,0),"hh:mm AM/PM") & " to " & TEXT((ROW(1:1))*TIME(0,30,0)+TIME(8,0,0),"hh:mm AM/PM")
Change each of the TIME(8,0,0) to the first hour you want to show.
If you want a different time block than 30 minutes, change each TIME(0,30,0) to the span desired.
Put 8:00 in A1 and drag down until your schedule ends.
In Another column, C1 in my example, insert the formula =A1+0.5/24 0.5 being a half hour in a 24 hour period. Again, drag down until your schedule ends.
Finally, enter =TEXT(A1,"H:MM AM/PM")&" to "&TEXT(C1,"H:MM AM/PM") in another column, and drag down until your schedule ends.
*If you don't want to see the columns with the start and end times, hide them or put them on another sheet.

Calculating time range in Excel

Assume I have such data:
29.10.2014 19:00 30.10.2014 7:30
29.10.2014 23:00 29.10.2014 18:00
30.10.2014 9:00 30.10.2014 23:15
31.10.2014 18:49 1.11.2014 7:15
How to get that time which is between 22:00 to 6:00. Like first example row 29.10.2014 19:00 30.10.2014 7:30 whole work time is 12:30 (12,5h) and work time between 22-6 is 8:00 (8h). How to get this 8h. Used some searches and find sumproducts, sumifs, countifs but didn't handle them by myself. :/
This article seems to answer your question:
https://office.microsoft.com/en-us/excel-help/calculate-the-difference-between-two-times-HP003056108.aspx
It's easier to calculate the time between 06:00 and 22:00, so assuming start time/date in A2 and end time/date in B2 use this formula to get decimal hours
=(MOD(B2,1)< MOD(A2,1))*(22-6)+MEDIAN(6,22,MOD(B2,1)*24)-MEDIAN(6,22,MOD(A2,1)*24)
That also assumes that end time will either be the same day or the next, is that right?
To get 22-6 time just calculate total time minus the above, so if the above is in C2 use this in D2
=(B2-A2)*24-C2
I assume that your second example is an error because start time/date is after end time/date

Resources