Getting minutes between different dates in excel - excel

I'm trying to calculate the time between the dates , at the beginning the formula
was working fine but I've noticed that it does not work when the date is different
For example , I have the following information on cell A1: 09/15/2016 10:00 AM
On Cell B2 I have: 09/16/2016 10:00 AM
The formula is just B2-A1 but instead of giving me a result of 24 hours is just giving me 0 . I believe the formula is not recognizing that these are 2 different days and is just doing 10-10
Any idea how to fix this ?

I was able to get the result 24 by setting a custom format of [h] (you will have to type it into the 'Type:' box) on cell C1 while using the formula =B1-A1
Excel Reference
'Format Cells' view
The problem with just using =B1-A1 is that if either or both of those cells is not populated then you will get weird numbers in C1. You may want to make C1 display as a blank cell unless both boxes are populated, try something like this =IF(OR(ISBLANK(A1),ISBLANK(B1)),"",B1-A1)
The reason for the weird numbers is that Excel calculates time based on a predefined decimal system that indexes time starting at like 1/1/1900 or something like that. So when manipulating or calculating time, that is something that you always have to keep in the back of your mind.
Hope this helps.

Formation the destination cell to will do but since you have date and time combined it will show as 1 calendar day difference 0 only means that 12 am after the 1 day difference, I know it does not make any sense but its Excel...
If I was you, on column A, I would add the date, and on Column B, the time.
then just work with the time, as both combined can be tricky
Don't forget to format your cells!! (right click>Format Cells>Time>3/14/12 1:30 PM)

Related

Excel if statement produces `#NUM` unexpectedly

I have searched and tried different things but I just can't seem to make this formula work. Background on what I am trying to achieve:
There are two dates in play here,
Application date (cell B5) 'which everyone has
and
Retirement date (cell F6) 'which only some people have, provided they have retired
If there is no retirement date, return nothing (works)
If the difference between F6 and B5 is greater than or equal to 15 months, display RTR>15 (works).
Otherwise display nothing even if the difference is negative (gives #NUM value in the cell when date difference is less than 15).
Formula I used:
=IF(F6="","",IF(DATEDIF(F6,B5,"m")>=15,"RTR>15",""))
It all works except when the difference between the two dates is less than 15 then it displays #NUM in the cell in red. So I am assuming I need to have a condition in there to handle negative values? but how can I fix this?

Trouble with looking up min value between different conditions

I am trying to find the minimum time for a fixed date between two different times.
Been trying out different variations but nothing works.
This is on excel 2016, I tried out yesterday with a similar code on a different spreadsheet (a test sheet I created) and it worked. Unfortunately it was on another laptop that I have no longer access to.
Tried out the same code on the sheet I am to use and it did not work.
{=MIN(IF((Date<=D5)*(Date>=D4);Time;"");IF((Time<=D7)*(Time>=D6);Time<""))}
{=MIN(IF(;IF((Time<=D7)*(Time>=D6);Time<""))}
D5 is the actual date I want to look at (line 1), since it did not work for my I tried out putting an earlier date in D4 but same result (line 2).
D7 and D6 is the end and start time I want to find the value between.
Tried naming the ranges so Date range refers to the dates (E2:E55220) and Time is the time range I want to find the minimum value in (C2:C55220).
Value I end up with on all attempts is 0
Alternative formula to the array. It should do the same thing:
=AGGREGATE(15,6,myTIME/((myDATE<=F4)*(myDATE>=F3)*(myTIME<=F6)*(myTIME>=F5)),1)
Now this formula works with the assumption that your dates are actual excel dates and not text looking like a date. Same goes for for time. You can test it with the following formula:
ISNUMBER(E2)
or
ISTEXT(E2)
Where E2 is a cell containing a date or a time. Excel stores dates as integers and times as decimals. IF your information is stored as text, it is probably easier to convert them first then trying to apply your formula con the converted results. you can convert withing your formula but it will tend to make the formula really ugly and long.

Using the 'TODAY' function

My spreadsheet is to show me how many days active a certain field has been.
For this I am trying to find a formula which will automatically take the entered date from one cell and deduct it from "todays" date.
As an example I have used =DATEVALUE("22/04/2017")-TODAY() - and although this works, i am unable to drag the formula down into other cells, to auto populate when a date has been entered/ amended. I'm having to enter the formula above every time, and if the date changes, as an example from the 22/04/2017 to the 20/04/2017, I would have to manually amend the formula too. How can I get it just pick up the date in that particular cell and deduct "today" from it?
Sorry if i'm rambling, I just don't know if I'm explaining myself properly.
Thank you
Typically, 'how many days active a certain field has been' would be a positive number (i.e. the number of days). Reverse the subtrahend and minuend to get a positive integer like this,
=today()-a3
To avoid getting 5/15/2017 or 42,870 as the result when A3 is blank, check to see if there is something in A3 before attempting subtraction.
=if(len(a3), today()-a3, text(,))

How do I deduct time in excel cells with out causing #### error?

I am trying to deduct time in excel.
There are 2 cells and I'm trying to do = with cell1 coordinates - cell2 coordinates.
This is working fine in most of the sheet with the cells formatted as custom hh:mm
In these particular cells I'm getting ########### rather than the answer
Upon looking further in to why this is happening one of the cells in the calculation is simply showing the time whilst one is showing 07/01/1900 00:57:30 in the top bar. The cell is also formatted to HH:MM so why does it show a date in the bar at the top rather than just the time??
I believe I'm getting the ##### error because on the cell it looks like the above and the other just shows the time as
04:42
How do I stop the first cell from looking like a date plus time in the formula bar?
If the cell with 07/01/1900 00:53:30 is supposed to be a time then you should consider it as indicating 7 days offset in time (assuming that format is dd/mm/yyyy). I get the same results if the cell number is 7.039930556, and I format it for HH:MM.
However that number was generated, it has an offset of 7 days (suspiciously one week!). I suggest looking at how it was generated, it might be due to a wrap around issue.
If you really just want the time value and don't care why there is an integer offset, you can use the function MOD MOD( A1, 1) will return only the fractional amount of the number, which represents the fractional amount in a day, which is the time.
Excel time and date is representing in days since Jan 1st, 1900. 0.5 is 12 hours. 0.1 is 2.4 hours.

Can I use the CountIf function to count the # of cells containing certain date keywords?

I have a set of data that looks something like this:
11/8/12 5:20
11/7/12 15:57
11/7/12 13:51
11/7/12 10:47
11/7/12 8:00
Just in Excel, I want to be able to count the number of rows with 11/8/12, and the number of rows beginning in 11/7, etc. I have a pretty long list of dates and times, but I'm only interested in the dates.
I tried =COUNTIF(A1:A235, "<11/8/12 5:20") to get everything before 11/8, but obviously this doesn't work because I need to type in the time. Does anyone know how to:
1) make the timestamp irrelevant?
2) somehow search for rows that "contain" a certain date value and count up the rows that contain that value?
You can insert in a cell e.g. F7 the date which should be used
and then your formula will look like this
=COUNTIF(E8:E12;"<"&F7)
And then in case that your F7 will contain 11/7/12 14:00 the countif will return 3
NOTE: expecting the british date 11/7/12 is dd/mm/yy
EDIT: Date function
When I've seen another answer, I would like to show another approach, which is culture safe. Whenever we will put some strings representing dates, it could happen that a collague has different regional settings (e.g. British dd/mm/yy vs US mm/dd/yy)
That's why I placed the date into separated cell, representing the Date regardless of the culture. If that all have to be placed inside one cell, the correct approach is to use Date function
=COUNTIF(E8:E12;"<"&DATE(2012;7;11)+TIME(14;0;0))
In Excel dates are integers and the time is a fractional value so you can simply count between one date and the next (date +1) to get everything on a single date, e.g. for everything on 11/7
=COUNTIF(A1:A235, ">=11/7/12")-COUNTIF(A1:A235, ">="&"11/7/12"+1)
or in Excel 2007 or later you can use COUNTIFS
=COUNTIFS(A1:A235, ">=11/7/12",A1:A235,"<"&"11/7/12"+1)
for either one you can use a cell reference with the date as Radim suggests, i.e. with date in B1
=COUNTIFS(A$1:A$235,">="&B1,A$1:A$235,"<"&B1+1)
With that last version you can simply list all your dates in B1 down, and then use the formula in C1 copied down to get counts for each date

Resources