Issue with negative value when using NETWORKDAYS - excel

I have created the formula
=-1+NETWORKDAYS(I18;J18;Helgdagar!A8:A35)
to calculate the difference between two dates. Standard Excel behaviour is that if it is the same date in both columns, it shows the value 1 but I want to display the value 0 instead (hence the -1+ in the beginning).
So far so good. The problem I have with this formula is if the date in J-column comes before the date in I-column. Let's say that it says April 8th in the J-column and April 10th in the I-column. Then it should say -2 but instead it says -3. How can I solve this?

=-1+IF(J18<I18,NETWORKDAYS(J18;I18;Helgdagar!A8:A35),NETWORKDAYS(I18;J18;Helgdagar!A8:A35))
Put an if statement in to compare which is the smaller value and then use the appropriate formula that works for you.

This is a way I have used:-
=NETWORKDAYS(I18;J18;Helgdagar!A8:A35)-sign(NETWORKDAYS(I18;J18;Helgdagar!A8:A35))
So it subtracts 1 if the NETWORKDAYS result is positive (including the case when both dates are the same) and adds one if it is negative.

Related

LEN function in Excel not returning a numerical value

I'm having a strange issue here with Excel. I'm working with a custom datetime format in one column...
9/1/2017 12:02:01 AM
This is cell C2. However, using LEN on this cell gives me this...
1900-01-15 00:00:00
I've tried changing the format to General, or Text, and messing around with some custom datetimes, but it doesn't help. I will get the same answer. My goal here is to use this as an exercise and trim the date and time, putting them in separate columns. This spreadsheet was originally created using Google Sheets, not sure if that might explain it?
UPDATE: Ok, so about 1 minute after posting this I think I figured it out? I used LEN in the column to the left of column C, so B. I had been using column D. For some reason, column B returned the numerical value. Obviously I'm very new to Excel. I didn't think column placement mattered in this case. Why does it?
That's because you have formatted the result to be shown as a date.
Remember, dates are simply really large numbers. So, what has happened here is that you get the correct result from LEN(), but then you have formatted this result to be interpreted as a date.
The date seems to indicate the result was 15. In dates, this is 15 full days from 1900 January 1st.
So, you just have to change the format of that cell from a date, to be a number :)

If function with formula to calculate difference between dates

I am trying to find a difference between 2 dates using networkdays and additionally if both dates are equal, have to make the value as 0. But unable to get the result.
You can try
if(DATEVALUE(A1)=DATEVALUE(A2),0,NETWORKDAYS(A1+1,B1)
#Ron Rosenfeld has pointed out that my testing led to wrong conclusions. Therefore I increased the volume of my tests. They continue to show that ...
Comparing the two dates and adding a day gives erratic results, and that
The naked NETWORKDAYS function as designed by Microsoft gives the most useful result.
In the table below the original function is in column C, your function (modified to work by #Ron Rosenfeld) in column D and two variations thereof in columns E and F. The lower part of the table shows results where both days are the same while the dates are 2 days apart in the upper part.
The tables show that the original formula counts both the start and the end days as well as all days between them, subtracting weekend days, except when start and end days are the same. In other words, the original function already treats the case of A1=B1 differently.
However, if an adjustment is to be made it should preferably be made to the result of the formula, not be modifying the date before they are processed. This is demonstrated in column F.
The formula in column E takes up your attempt to modify one of the dates (the end date could be modified too) and makes this conditional. The difference as compared to your formula is that you apply in fact two separate calculations, one where the result is always 0 (when dates are equal) and the other where the start date is advanced by one day unconditionally. If it suits your purposes that method can still be applied but the formula in column E shows how the date modification can be made conditional.
The need to apply conditions arises from the essential shortcoming of your formula in that it applies the wrong condition. Different treatment for when dates are equal is already incorporated in the basic function. Any further modification must take the involved weekdays into account, not (necessarily) only the interval between the dates.
Why do you put your formula arguments in quotes? That just changes them into strings, which is why your formula doesn't work.
I assume from your formula that you just don't want to count the first day. In which case it will work as you have it, if you merely remove the double quote marks.

sum if weekday is equal to the weekday excel

I would like to solve some syntax error due to lack of skills. I would like to bind this weekday check with one formula.
This is wrong and I need to sum up the (W11/X11*Y11*1.25) part and showing the day of transaction is only on weekday and not weekend on Z11. Meaning to say I need to bind this formula together and then sum for the rest blanketed columns on Cell Z11.
=((T11/X11)*Y11)+((U11/X11)*Y11*1.25)+((V11/X11)*Y11*1.5) with =IF(AND(WEEKDAY(A11)>=2, WEEKDAY(A11)<=6), (W11/X11*Y11*1.25))
Thank You In Advance
=IF(WEEKDAY(A11)=2,"Monday",IF(WEEKDAY(A11)=3,"Tuesday",IF(WEEKDAY(A11)=4,"Wednesday",IF(WEEKDAY(A11)=5,"Thursday",IF(WEEKDAY(A11)=6,"Friday")*(W11/X11*Y11*1.25)))))
No error message, the syntaxs is wrong
Your formula does not produce a syntax error for me. It returns the day of the week in words and it works exactly as written.
In the IF statements you return the day name as text. The text for Friday is then multiplied by (W11/X11*Y11*1.25) . Since text will not be multiplied with numbers, the result is still text.
You probably don't want this. You probably want the calculation to occur only for weekdays, so you could use a formula like this
=IF(and(WEEKDAY(A11)>=2,WEEKDAY(A11)<=6),(W11/X11*Y11*1.25),"no calculation")
In words: if the number of the weekday is between 2 and 6, do the calculation.

`10/2` evaluates to `42279.00`?

In Excel, I have a cell value as number format, say 10/2. It displays as 10/2 but I would like 5.00.
It evaluates to 5.00 if I add an = before it i.e, =10/2, but I don't want to have to edit around 500 rows of that column.
I tried to use VALUE function but it evaluates it to 42279.00:
Cell B1 10/2
Cell B2 42279.00
Another data example is: 100/20.
Can you please tell me what has gone wrong, or is there any approach to get the cell value 10/2 to be evaluated to 5.00?
Please try applying a formula of the following kind to all your data:
=MONTH(B1)/DAY(B1)
Having done so you may select the results, Copy and Paste Special over their source (assumed to be ColumnB) and then delete the formulae.
Excel has, trying to be helpful, interpreted your entries as dates - the above should reverse the coercion.
Since now it seems not all entries have been coerced into dates, I suggest for those that have not:
=LEFT(B1,FIND("/",B1)-1)/MID(B1,FIND("/",B1)+1,LEN(B1))
The problem is that you’re putting in what you’re thinking of as a calculation (ten divided by 2), but you’re not saying it’s a calculation (no “=”) so excel is looking at it as a value. When it looks at “10/2” it thinks “that’s a date, October second!” and it treats it as a date.
Dates are actually kept as numbers. If you had the column formatted as date or general, it could display as a date. But I’m guessing you have the column formatted as a number so it’s giving you the numeric representation of October 2, 2015.
The bad news is that as far as I know you would have to get the “=” in somehow, or do the calculation and replace it with 5 (10 divided by two would never be other than 5. If the latter you could select the column and do a replace 42279 with 5.

Date comparison not working in Excel formula

If I put the date 31/12/2013 in A1 and another date 1/1/2014 in A2 then a formula like
=A1<A2
gives the expected result, TRUE.
If I put the formula
=A1<1/1/2014
in another cell, it gives the result FALSE.
The question is how to adjust the second formula to make it give the correct result, and why it doesn't work as it stands.
I've been looking at this for a while and have found some related posts like
Comparing computed dates with entered dates
but not one which directly answers the question.
1/1/2014 is 1 divided by 1 divided by 2014.
Instead; =A1<DATEVALUE("1/1/2014")
I can answer my own question now.
The answer as mentioned in related posts is to use the DATE or DATEVALUE functions i.e.
=A1<date(2014,1,1)
or
=A1<datevalue("1/1/2014")
The reason it doesn't work is that in this context Excel just sees 1/1/2014 as an arithmetic expression, one divided by one divided by 2014 which is a small number. Dates (number of days since 1/1/1900) generally evaluate to large numbers so the comparison fails.
If you just type 1/1/2014 into a cell you get a date, but if you type =1/1/2014 you get a small number.
I just thought it was interesting to share because to a human =A1<1/1/2014 looks as if it's comparing a cell with a date, but it isn't.

Resources