J
Jan T.
I am trying to count days in a period i.e. a month + having a start date
and an end date to calculate from.
I have too columns for log dates. These are:
StartDate EndDate
Now I want to calculate how many days is there within a given month.
To acheive this, I figure I had to add some moore columns and add
some data to them. The columns From and Until is the period which
a want to measure. In this case that would be the month February.
How many days in February is there (NumOfDays) if StartDate and
EndDate are as the following example below?
StartDate EndDate | From Until
NumOfDays.
--------------------------------------------------------------------------
02/01/08 02/03/08 | 02/01/08 02/29/08 3
01/25/08 02/03/08 | 02/01/08 02/29/08 3
02/03/08 02/03/08 | 02/01/08 02/29/08 1
02/29/08 03/01/08 | 02/01/08 02/29/08 1
01/29/08 03/03/08 | 02/01/08 02/29/08 29
03/02/08 03/03/08 | 02/01/08 02/29/08 0
What would the formula in the very right Column look like (i.e. NumOfDays
Column)
If I want the results as you can see them above?
I tried something like this:
=(MIN(Until,MAX(StartDate, FromDate) +1) - MIN(Until, MAX(EndDate, FromDate)
This works fine for almost all cases except for the last wich should
returned 0 and
not 1 as my formula gives me. Any suggestions?
Thank you very much for your help.
Regards
Jan
and an end date to calculate from.
I have too columns for log dates. These are:
StartDate EndDate
Now I want to calculate how many days is there within a given month.
To acheive this, I figure I had to add some moore columns and add
some data to them. The columns From and Until is the period which
a want to measure. In this case that would be the month February.
How many days in February is there (NumOfDays) if StartDate and
EndDate are as the following example below?
StartDate EndDate | From Until
NumOfDays.
--------------------------------------------------------------------------
02/01/08 02/03/08 | 02/01/08 02/29/08 3
01/25/08 02/03/08 | 02/01/08 02/29/08 3
02/03/08 02/03/08 | 02/01/08 02/29/08 1
02/29/08 03/01/08 | 02/01/08 02/29/08 1
01/29/08 03/03/08 | 02/01/08 02/29/08 29
03/02/08 03/03/08 | 02/01/08 02/29/08 0
What would the formula in the very right Column look like (i.e. NumOfDays
Column)
If I want the results as you can see them above?
I tried something like this:
=(MIN(Until,MAX(StartDate, FromDate) +1) - MIN(Until, MAX(EndDate, FromDate)
This works fine for almost all cases except for the last wich should
returned 0 and
not 1 as my formula gives me. Any suggestions?
Thank you very much for your help.
Regards
Jan