T,
If the start date is in A2, and the end date in B2, you could use:
=MAX(0, MIN(B2,DATEVALUE("2/28/05")) - MAX(DATEVALUE("2/1/2005"), A2)+1)
This gives the days, inclusive, for February. You'd have to manually change
the dates for other months. It can be made more general for other months,
but it gets more messy. It should work across years. If it comes up as a
date rather than a simple integer, remove the date formatting with either
Format - Cells - Number, or clear all formats (Edit - Clear - Formats).
The MIN gives either the end date, or then end of the month if the end date
is greater than (after) the end of the month. The inner MAX gives the start
date, or the beginning of the month if the start date is before (less than)
the beginning of the month. Then they're simply subtracted. The +1 makes
in inclusive, instead of a difference. The outer MAX is there for cases
where the both the start date and end date are before or after the month of
interest (Feb). In such cases, the difference comes up negative, so the MIN
is used to return 0.
--
Earl Kiosterud
www.smokeylake.com
"tesouthworthjr" wrote in message
...
I am creating a spread sheet to identify the number of days a patient was
on
a particular ward. sometimes, the patient is a resident for a span of time
that includes several different months. What I need a formula that will
break
down the number of days the patient was in admittance for each different
month:
Example:
John Doe 1/5/05 through 3/7/05
What is required is to calculate the number of days for each month,
separately.
Jan Feb Mar
? ? ?