Calculating month number by knowing difference between two days as number - excel

I have days as number which will give difference between two dates... For example : 01-03-2015 and 03-04-2015. I will get difference as 33 days. Now how to know this 33 days comes in which month... like 380 days comes in 13th month

I think I see what you're trying to get. How about something that just rounds the difference divided by 30?
Say your 16-07-2015 is in A1, and 30-07-2016 is in A2. In B1, =Round((A2-A1)/30,0)

If you want 31-01-2015 and 01-02-2015 to evaluate to 1 month (althought it is only one day) you could use something like =MONTH(A2)-MONTH(A1)+12*(YEAR(A2)-YEAR(A1)) where A1 and A2 are the two dates.
Otherwise something similar to Batma... I mean BruceWayne would work.

Related

Excel | Calculate the time difference

I'm trying to calculate the difference in working hours. Depending on the amount, 30 minutes should be deducted for more than 6h (or equal to 6h) (corresponds to the break during working hours). If the working time is less than 6 hours, nothing will be deducted.
My formula in cell E2 looks like this.
=IF((D2-C2)>="6:00";D2-C2-"00:30";D2-C2)
(All cells have the time format.)
But this formula doesn't work. In the example above, I actually expect 9:30, but it outputs 10h.
Where is the mistake?
it is because it sees "6:00" as text and does not convert it to a time.
add -- before the "6:00"
=IF((D2-C2)>=--"6:00";D2-C2-"00:30";D2-C2)

Excel: Comparing Times to get minutes apart

I'm trying to get the + and - between two times but if the time I am subtracting from is greater than the time I am subtracting it gives me the difference in 24 hours.
I would like it to show this:
Perhaps this needs to be done in VBA. Have column B be the time to compare to and put max time apart as 12 hours, either positive or negative. So if the time is different by over 12 hours it becomes a negative instead of positive or vise-versa?
#tysonwright that is the best way to do it. Thanks. I assumed there was a better process but apparently there is not. So with that, I change the date to the next day to get 23:59 to 0:01.
If your clockin is in A1 and your Schedule is in A2, your Difference should be:
=IF(A1>B1,TEXT((A1-B1),"-h:mm"),TEXT((B1-A1),"h:mm" ))

Excel Subtracting time

Currently trying to setup a formula that will calculate the hours/minutes between two different hours of time.
I currently use the following formula in Cell D3 and receive 12:35am as the answer:
=C3-B3
What I would want it to display is 35 minutes, which is the correct amount of time in between (6:42AM and 7:17AM).
Something like this would work:
=TEXT(C3-B3,"[m]")
or if you want "minutes" written after
=TEXT(C3-B3,"[m] ""minutes""")
Examples:
C3-B3 and formatted as [m] will work - either =TEXT(C3-B3,"[m]") or just giving the cell a custom number format of [m].
If Begin is 11:45PM and End is 12:15AM you'll only see ############# as both times are considered to be in the same day, while 12:15AM is the start of the next day.
Try =IF(C4<B4,(1+C4)-B4,C4-B4)
If C4 is less than B4 it adds 1 day to the value of End.
You have to multiply your formula by the amount of hours in a day (24) and the amount of minutes in an hour (60) in order to convert.
So your formula should be the following.
=(C3-B3)*24*60

Number of Hours Between Two Dates Not Working in Excel

As requested, I have included a simplified screenshot that illustrates the issue.
As you can see, I subtracted the two dates and formatted it as "h:mm:ss". Why doesn't this give you the total amount of hours that have passed between the two dates? Is there a better way to do this? There is a great answer below, but I am trying to figure out why doing the way illustrated in this screenshot doesn't work.
END OF EDIT
I am aware that similar questions have been answered here, but for whatever reason this is not working for me at all.
I have two columns: one is a date, one is the time.
As you can see from the currently highlighted cell, the "time" column is actually stored as date with the time included. In column H, I have the date stored as a serial code so that the decimal number refers to a month, day, year, hour, minute, and second. When I subtract the serial code that refers to 2/16/2016 3:20:01 PM from the serial code that refers to refers to 2/14/2016 1:20:01 PM and format that cell as "h:mm", I am getting 2:00. Why?????
I have been hacking away at this for a while and this is supposed to be stupid easy and it's not working. Any help is greatly appreciated so I can move on to more important things.
It does work. Just take the difference between the two dates, format the cell containing the difference as Number, and then use one of the following formulas to get the units you want. I will assume that:
A1 has the value 2/16/2016 3:20:01 PM
B1 has the value 2/14/2016 1:20:01 PM
Into C1 enter A1 - B1, and format it as Number
If you want the difference as days, leave C1 as is.
If you want hours, use =24*(A1 - B1)
If you want minutes, use =24*60*(A1 - B1)
If you want seconds, use =24*60*60*(A1 - B1)
THE ANSWER TO THIS IS REALLY SILLY.
Below, you will find that Tim Biegeleisen provided an excellent answer to this question. I just wanted to further elaborate.
Sometimes having too many option for formatting can be a problem, which is what happened here.
When you subtract 2/14/2016 1:20:01 PM from 2/16/2016 3:20:01 PM and format it as h:mm:ss it only subtracts the hours portion and ignores days. You just have to somehow know that if you are trying to do what I'm trying to do, you have to format it as [h]:mm:ss and then it will calculate the total number of hours passed. The bracket around the "h" is the important part here. I hope this helps the next person who comes across this.

Hours to working days

Where I work I don't get paid overtime, but I accrue holiday days for the overtime I work. I have the following spreadsheet which calculates how much overtime I've done and totals it in D15.
Now I want to calculate how many days this is, based on 8 hours per day. In D16, I've done =D15/8 and formatted it as h.mm \d\a\y\s, but this shows as 2.26 days instead of 2.4375 days.
What is the correct formula to use in D16?
Note to reader: this question led to multiple solutions some of which were discussed in the comments. Here is a summary of the solution found.
First solution
=(HOUR(D15)+MINUTE(D15)/60)/8
Explanation
Dates and time in Excel are stored as serial numbers, so 19:30 is actually 0.8125.
So, if you divide it by 8, you will get 0.1015625.
This latter value is worth 2.26 days
OP's version (thanks to Danny Becket (OP)) - see the comments below.
This solution now handles hours > 24.
=((DAY(D20)*24)+HOUR(D20)+(MINUTE(D20)/60))/8
or better (credits to Barry Houdini):
=((INT(D20)*24)+HOUR(D20)+(MINUTE(D20)/60))/8
The former formula has a limitation for large values, perhaps not relevant here but if D20 is 800:00 then you get the wrong answer (7 days rather than 100 days). This is probably because DAY function is giving you calendar day which will "reset" at 31, best to use INT in place of DAY.
Another easily understandable version
Divide by the length of the day as a time value:
=D15/"8:00"
More easily changed if length of workday changes
Enter:
in B3 8:3
in C3 16:3
in D3 =IF(B3<C3,C3-B3-1/3,2/3-B3+C3)
Select B3:D3, format as hh:mm and copy down as far as required.
Sum ColumnD and append *3 to the formula, but format as Number.
Add data by overwriting cells in ColumnB and/or ColumnC as required (defaults do not add to total).
Copes with overtime up to next regular start time (ie including past midnight, new serial number). 1/3 because standard working day is 8 hours (24 hours is unity for date serial counter). B3 and C3 could be hard coded but (i) there is no need and (ii) allows more flexibility. If to readily identify non standard start/finish could use conditional formatting.
Does not address weekend overtime but could easily be adapted to do so (eg add column, flag weekend day with 8 in that extra column then add that 8 [1/3] to the finish time).
Make sure that D15 has a number format of [h]:mm
then have D16 as =sum(D15/"8:00") should work fine
thats what i have tracking my annual leave, I work 37h pw with a leave day being classed as 7h24m or a half day of leave as "3:42"
I have leave taken as a cumulative figure assigned as [h]:mm in cell K2 of my spreadsheet
then I have K3=SUM(K2/"7:24") for days taken formatted as a general number
you may also need to change the date datum in excel to the 1904 date system http://support.microsoft.com/kb/182247/en-gb
to get this to work (only a problem if you have negative time as I do when calculating flex hours)

Resources