We'd like to remind Forumites to please avoid political debate on the Forum... Read More »
Excel formula help please

Gers
Posts: 12,979 Forumite


in Techie Stuff
I'm trying to calculate the number of days between the two dates and have copied the formula directly from the MS support website but it's not working. Can anyone tell me how I've gone wrong please? Thanks.
Mine:

MS's:

0
Comments
-
Try changing the number format of the 3rd cell to just a plain number.1
-
That should work and if the cells are formatted as general which is default then that is fine.
Click on the fx to the left and that will bring up the functional arguments box and check it looks right there and if not it may give clues.1 -
As a tip for future, you didn't need to use the datedif formula for this. A simple =B1-A1 would deliver the same answer and generally no number format issues either.
Note though, these formulas whether simple or the datedif exclude the start date from the calculation so sometimes you need to add that back in - for example if you want to know how many days someone was employed for and they started on 1 Jan and left on 10 Jan. the formula will return 9 but they were actually employed for 10 days in total. So the fix for that is simply a +1 at the end of the formula =B1-A1+1 or =DATEDIF(A1,B1,"d")+11 -
Also - the dates in the MS example are written in the US format mm/dd/yyyy so if you wanted to compare answers you'd need to use 6 May 2016 as the end date!0
-
C =B-A works for me as a simple sum...
DATEDIF isn't a recognised function name in my (old) version of Excel...1 -
la531983 said:Try changing the number format of the 3rd cell to just a plain number.400ixl said:That should work and if the cells are formatted as general which is default then that is fine.
Click on the fx to the left and that will bring up the functional arguments box and check it looks right there and if not it may give clues.tizerbelle said:As a tip for future, you didn't need to use the datedif formula for this. A simple =B1-A1 would deliver the same answer and generally no number format issues either.Now that worked!Thanks. No idea why MS didn't offer that one up or why theirs didn't work. Anyway, sorted now. Thanks to all those who responded.
1 -
Gers said:I'm trying to calculate the number of days between the two dates and have copied the formula directly from the MS support website but it's not working. Can anyone tell me how I've gone wrong please? Thanks.Mine:
To get the date difference in days you can simply subtract one from the other (ie =A1-B1) or the other way round depending on if you want the number to be negative or positive.4 -
Rodders53 said:C =B-A works for me as a simple sum...
DATEDIF isn't a recognised function name in my (old) version of Excel...It's headed:
0 -
Not needed to sort out your problem now but could be useful info for another rime.....The datedif formula look fine and should work from earlier than the 2003 version. Can't remember from when but as noted is an early 'hangover function and not necessary for simple day count.It is useful though for other date calculations such as weeks months years etc so very flexible.The simple B-A calculation might give unexpected results if time is in the date cell and hidden in the result cell ( cell formated not to show decimal) and subsequently used in a calculation.Having a #Name error, I wonder if you do not have that in your formula list ( click the = sign to find out ) or perhaps, did you use the double quote symbol or two single quotes?1
-
As others have said, DATEDIF probably isn't the best function to use here in any case.....but if you get #NAME? error as shown then that might mean there's something wrong with the quote marks in the "d" part (they look a little odd on your screenshot).
Did you say you copied the formula? What happens if you just type it in afresh, does it work then?1
Confirm your email address to Create Threads and Reply

Categories
- All Categories
- 349.8K Banking & Borrowing
- 252.6K Reduce Debt & Boost Income
- 453K Spending & Discounts
- 242.7K Work, Benefits & Business
- 619.5K Mortgages, Homes & Bills
- 176.4K Life & Family
- 255.6K Travel & Transport
- 1.5M Hobbies & Leisure
- 16.1K Discuss & Feedback
- 15.1K Coronavirus Support Boards