ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   excel days counting formula (https://www.excelbanter.com/excel-programming/402011-excel-days-counting-formula.html)

krc547

excel days counting formula
 
what if I need to count number of days except if cell d17 is not the end of
the month. Example C17 and D17 are as follows:
c17=11/25/07 d17=11/29/07 instead of it returning 5 days I would need it
to return 4 days because the client was not here until the end of the month.
But I currently have this in my cell: =IF(C17="","0",DATEDIF(C17,D17,"D")+1)

Bernard Liengme

excel days counting formula
 
How about:
=(D17-C17)+(DATE(YEAR(D17),MONTH(D17)+1,0)=D17)

The first term computes the number of days - there is no need for DATEDIFF
This give 4 in the case or 25 Nov to 29 Nov and 5 in the case or 25 Nov to
30 Nov.

The second then checks is the D17 date is the end of the months and, if so,
adds 1

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
www.stfx.ca/people/bliengme
remove caps from email

"krc547" wrote in message
...
what if I need to count number of days except if cell d17 is not the end
of
the month. Example C17 and D17 are as follows:
c17=11/25/07 d17=11/29/07 instead of it returning 5 days I would need it
to return 4 days because the client was not here until the end of the
month.
But I currently have this in my cell:
=IF(C17="","0",DATEDIF(C17,D17,"D")+1)





All times are GMT +1. The time now is 08:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com