Excel date difference #Value error - excel

I have two columns:
C2=4/27/15 11:00:26 AM
D2=4/27/15 11:01:46 AM
I'm trying to calculate the time difference in seconds using the formula
=(D2-C2)*24*60*60
But I'm getting #Value error.

Generally a #VALUE error means you are trying to do math on a text value. One of your dates is probably in text format.
Try retyping your dates and see if that makes your formula work.
If you need to have the actual seconds in a number you can use elsewhere then your formula should work, if the dates are in the correct format.

Here are the specific ways to get the time difference between two dates in two different cells - notice the cell format is important:
https://support.office.com/en-ca/article/Calculate-the-difference-between-two-times-e1c78778-749b-49a3-b13e-737715505ff6
And the DATEDIF function gives you the difference in days/months/years
=DATEDIF(C2,D2,"M")

You should use the INT function
=INT((D2-C2)*86400)
And as #Tember mentioned, cell formats are important..

Related

Dates are not recognized

I have written a conditional formula to recognize two dates (greater than and last than). However, there are a few dates that are returning 'false'. All of the columns are formatted as a date. Can someone please help?
This is not a direct answer to the question asked, but as Scott said, the formula you use is much more complex than necessary. If you need to return a number for a date that falls within a period and the periods do not overlap, the following formula can be used:
=SUMPRODUCT((AQ3>=$DF$3:$DF$15)*(AQ3<=$DF$3:$DF$15),$DH$3:$DH$15)
If you need to process text values, it is more complicated. For example, if 'expired' is the only value (also for dates that do not fit into any period), then we can add the IF function to the previous formula:
=IF(SUMPRODUCT((AQ3>=$DF$3:$DF$15)*(AQ3<=$DF$3:$DF$15),$DH$3:$DH$15)>0,SUMPRODUCT((AQ3>=$DF$3:$DF$15)*(AQ3<=$DF$3:$DF$15),$DH$3:$DH$15),"expired")

COUNTIF function shows a date instead of a number as a result

I was creating a frequency worksheet for the new classes i'll be taking this semester, but when i try to use the COUNTIF function as a sum of three different parameters, i always get a date (like 00/jan) as the result, not a natural number as i'd expect.
I've tried using the function COUNTIFS instead, only to achieve the same result.
The function i was trying to create is
=COUNTIF(B5:B23;"*criteria1*")+COUNTIF(B5:B23;"*criteria2*")+COUNTIF(B5:B23;"*criteria3*")
With COUNTIFS, it is as follows:
=COUNTIFS(B5:B23;"*criteria1*";B5:B23;"*criteria2*";B5:B23;"*criteria3*")
There is no error message, and all i want to get is a real number, that is, the real sum of those "criteria" appearing in the given interval.
Excel tries to be helpful and takes a guess at the data type of the formula cell.
Unfortunately, Excel often gets it wrong. Especially when the formula processes dates, Excel will often format the cell as a date, too, even though the result may not be a date at all.
Your only option is to manually apply a different format to the cell. General or Number will show the real number.

Unreasonably large negative number when using =NETWORKDAYS()

Hi there I am trying to use the =NETWORKDAYS formula in Excel to calculate the number of workdays passed between two dates minus public holidays on a separate sheet. When I enter the correct formula I get an unreasonably large negative number like -29221 workdays between 2017-04-28 to 2018-04-24. I've tried to change the NumberFormat of the cells, ignoring public holidays etc. but I still get these numbers. Am I doing something wrong?
Here's my formula:
=NETWORKDAYS(2018-4-24,D2,PUBLIC_HOLIDAYS!E44:E61)
Couldn't find anything on the internet that would solve this.
2018-4-24 probably isn't being read as a date value, insert it into a cell and change to general to get it's "value" or use it in Date() like so:
=NETWORKDAYS(DATE(2018,4,24),D2,PUBLIC_HOLIDAYS!E44:E61)
Static date is being read as text. Enclose it in quotes or use date function. Consider these options:
=NETWORKDAYS("2018-4-24",D2,PUBLIC_HOLIDAYS!E44:E61)
OR
=NETWORKDAYS(DATE(2018,4,24),D2,PUBLIC_HOLIDAYS!E44:E61)
If it still doesn't work, check the cells that you're referencing. Make sure you're referencing dates or its equivalent value and not some random numbers.
Hope this helps..

Excel: Subtracting Dates Without Reference Cells

I want to program a cell to calculate the number of days I have left before I meet a deadline.
I would like to do this without reference cells, unlike this tutorial.
An (incorrectly formatted) example of the kind of formula I want would be:=(3/2/2015-TODAY()), where 3/2/2015 is my deadline. This yields some negative serial number,-42051.00, which yields a #NUM! error when put into the DAY formula.
Any idea how to do this without putting TODAY() and 3/2/2015 into their own reference cells? I would like to use functions to keep these paraments completely embedded in the formula.
Right clock the cell with the answer and reformat it as NUMBER. You want to use the Days function not the date function.
=DATE(2015,3,2)-TODAY() is what you want, but I would recommend doing the date in a separate cell for a number of reasons and using "today()" in the formula.
EDIT: Anyone trying to find midpoints would use the date function in this case.
Also, as a general rule for people trying to subtract dates the two trouble shooting methods you want are
A) Check your format-If you want number of dates, it needs to be set as number, if you want a date, you need it to set as date. If you get a long decimal it means you have it formatted as general OR your expression returns a date value rather than a number value. Refer to my original answer.
B) Reverse your dates. Depending on the function and what you want, you may need to move the dates around.
=DATEDIF(DATEVALUE("03/02/2015"), TODAY(), "d")

Calculate difference in hours between two datetime columns in Excel

I have two columns in excel with datetime values and I want to get the difference between those two columns in hours.
If I try to subtract these two dates, I get #VALUE! in the resulting cell.
I tried to use datedif function of excel but it also gave me #VALUE! in the result cell.
I do not know how to get the difference.
If you are getting a #VALUE! error when simply substracting the dates, it means that at least one of those values is actually not a date but probably just a string. You may need to convert them to Date first.
To check if Excel thinks of your value as of date, try to set a different format of the date, or call a =DAY(yourCell) function on it. If it returns a number, it is a date, if it returns #VALUE!, it is not.

Resources