View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Bernard Liengme Bernard Liengme is offline
external usenet poster
 
Posts: 4,393
Default calculate number of days

With the first set of From and To dates in B2 and C2, respectively
=(MONTH(C2)=1)*DAY(C2)+(MONTH(C2)1)*31-(MONTH(B2)=1)*DAY(B2)
With From 06/01/2009 and To as 12/02/2009, this gives 25
While 05/01/2009 and 09/01/2009 gives 4
You may need to add 1 to the formula to make an 'inclusive' count

I have not allowed for more than 365 days between the two dates
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Bazy2k" wrote in message
...
Hi guys.

Ok i have items that run between two dates, each month i have to calculate
how many days in that month relate to that item, eg. in Jan

Item From To Jan Days

a3 14/11/08 16/02/09 x
a4 19/12/08 09/01/09 x

So x = 31
x = 9

Is there a quick way to produce the number of jan days for each item
between
the two dates using a formula? Maybe linked to a date of 31/01/09? and
then
when i change the date to feb (28/02/09) the number of feb days are shown?
I have a long list of items you see and want to make the process faster!
Thanks!