Unreasonably large negative number when using =NETWORKDAYS() - excel

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..

Related

Excel Date Countifs

I need to count all dates that are "less than" today to see which work is overdue. I understand that this can be done simply with
=countif(F:F,"<"&TODAY())
However, the dates in Column F are formatted like "12/05 - Evening" instead of just "12/05". Because of this, the formula is not picking up anything. Does anyone know how to change this code so that it counts any cell that contains dates prior to today, even if there is other text in the cell? I've tried playing around with these "**", but can't get it to work.. Thank You!
So based on my comment I would get the date by using left() with find() like so:
LEFT(A1,FIND(" ",A1,1)-1)
Then format as short date and it behave as a date.
From comment:
Use a helper column and separate the date out then use the countif() on that column

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")

Is there any way to use a wildcard in order to count dates?

Is there a way to use a wildcard to count the partial string of a date?
In my spreadsheet, I want to use the COUNTIF function to count a certain date. However, the date value also contains the time.
Example: "12/06/2017 17:35:12"
I only want to include "12/06/2017"
This is the formula I have: =COUNTIF(Pivot_Data[Created Date],"*12/06/2017*")
If I recall correctly, you must use the "&" concatenation operator on the wildcard symbol instead of including it with the rest of your string. This is specific to the countif and sumif functions:
=COUNTIF(Pivot_Data[Created Date],"*"&"12/06/2017"&"*")
EDIT: Here is a solution for date formats instead of text formats:
=COUNTIFS(Pivot_Data[Created Date],">"&DATEVALUE("12/06/2017"),Pivot_Data[Created Date],"<"&(DATEVALUE("12/06/2017")+1) )
This works because the date is represented as an unique integer in Excel's date encoding, with the time as a decimal value.
Place * either side of the date.E.g. =COUNTIF(E9,"*12/06/2017*")
This is a wildcard match. Adjust range according to needs.
Instead of searching for a specific text, I would just check if the date is the same as Excel's built in serial number. Also I prefer SUMPRODUCT over COUNTIF.
Something like:
= SUMPRODUCT((FLOOR(Pivot_Data[Created Date],1)=DATE(2017,12,6))+0)
The FLOOR function (in this case) effectively just takes the date and removes any reference to what time it is on that date.
I think this way is better because it doesn't rely on the cell being a specific text format.
See below, I used this formula but replaced Pivot_Data[Created Date] with A1:A5 just to demonstrate that this formula works with sample data. As expected, the formula returns a value of 2 because the data contains two dates on 12/6/2017. Notice how it doesn't care what time it is.

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")

Converting a string to a date in a cell

I have 100.000 rows of data in Excel. Some of the fields are dates, but the fields in Excel are as text. I need these fields in number format including both dates AND time (e.g. 21.10.2011 13:10:50). Formatting the cells doesn't work because that doesn't change the datatype. I can pick out the date and time with formulas but not get them in the same cell.
So what I am looking for is the formula to calculate the number representation of a date (the one you see if you format a date as a number).
Have you tried the =DateValue() function?
To include time value, just add the functions together:
=DateValue(A1)+TimeValue(A1)
To accomodate both data scenarios you have, you will want to use this:
datevalue(text(a2,"mm/dd/yyyy"))
That will give you the date number representation for a cell that Excel has in date, or in text datatype.
I was struggling with this for some time and after some help on a post I was able to come up with this formula =(DATEVALUE(LEFT(XX,10)))+(TIMEVALUE(MID(XX,12,5))) where XX is the cell in reference.
I've come across many other forums with people asking the same thing and this, to me, seems to be the simplest answer. What this will do is return text that is copied in from this format 2014/11/20 11:53 EST and turn it in to a Date/Time format so it can be sorted oldest to newest. It works with short date/long date and if you want the time just format the cell to display time and it will show. Hope this helps anyone who goes searching around like I did.
The best solution is using DATE() function and extracting yy, mm, and dd from the string with RIGHT(), MID() and LEFT() functions, the final will be some DATE(LEFT(),MID(),RIGHT()), details here

Resources