Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Help need formula for working out date overlaps

Hope someone can help, I'm looking for a formula to work out date overlaps.
e.g.
If my key dates are 1/11/08 to 30/11/08
I want to auto calculate how many days the following overlap with my key dates
01/01/08 to 31/12/08
16/11/08 to 05/12/08
etc

thanks!
--
Liz
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,420
Default Help need formula for working out date overlaps

=MAX(0,MIN(KeyDateEnd,$B1+1)-MAX(KeyDateStart,$A1))+1

--
__________________________________
HTH

Bob

"liztownsend" wrote in message
...
Hope someone can help, I'm looking for a formula to work out date
overlaps.
e.g.
If my key dates are 1/11/08 to 30/11/08
I want to auto calculate how many days the following overlap with my key
dates
01/01/08 to 31/12/08
16/11/08 to 05/12/08
etc

thanks!
--
Liz



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,180
Default Help need formula for working out date overlaps

Try
1/1/2008 20/11/2008
9/11/2008 11/11/2008
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 915
Default Help need formula for working out date overlaps

Herbert Seidenberg wrote:
Try
1/1/2008 20/11/2008
9/11/2008 11/11/2008


Ah, a misplaced paren:

=MAX(0,MIN(KeyDateEnd,$B1)+1-MAX(KeyDateStart,$A1))+1
^^^
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 915
Default Help need formula for working out date overlaps

smartin wrote:
Herbert Seidenberg wrote:
Try
1/1/2008 20/11/2008
9/11/2008 11/11/2008


Ah, a misplaced paren:

=MAX(0,MIN(KeyDateEnd,$B1)+1-MAX(KeyDateStart,$A1))+1
^^^


If anyone is still looking at this, I wonder if there is an array
solution that will do it? I think such a solution could have much wider
applications that touch on set operations.

E.g., In general, given two series of discreet values, denoted by their
respective endpoints,

series A: a...b
and
series B: c...d

1) Determine how many values are common to A and B, or
2) (better) Enumerate the values common to A and B so they can be
counted, summed, etc.
3) (going a step further) Enumerate the non-intersect values of A and B

Anyone up for a challenge? I know I am--and I dabbled at this, but my
grasp of handling arrays is feeble at best.


  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default Help need formula for working out date overlaps

On Thu, 11 Sep 2008 03:27:01 -0700, liztownsend
wrote:

Hope someone can help, I'm looking for a formula to work out date overlaps.
e.g.
If my key dates are 1/11/08 to 30/11/08
I want to auto calculate how many days the following overlap with my key dates
01/01/08 to 31/12/08
16/11/08 to 05/12/08
etc

thanks!



=SUMPRODUCT(--ISNUMBER(MATCH(ROW(INDIRECT(A5&":"&B5)),ROW(INDIRE CT(KeyDateStart&":"&KeyDateEnd)),0)))

Where your dates of interest are in A5 and B5
--ron
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,180
Default Help need formula for working out date overlaps

The problem is that
1/11/08 to 30/11/08
when fully expanded reads:
1/11/08 12:00 AM to 30/11/08 12:00 AM
What we really want is:
1/11/08 00:00 to 30/11/08 24:00
which shortens to:
1/11/08 to 1/12/08
If we correct all the end dates this way and
remove all the +1's in Bob's formula, everything works.
Ron's formula now fails and it has problems
if we include odd times.
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,420
Default Help need formula for working out date overlaps

I don't think so!

--
__________________________________
HTH

Bob

"smartin" wrote in message
...
Herbert Seidenberg wrote:
Try
1/1/2008 20/11/2008
9/11/2008 11/11/2008


Ah, a misplaced paren:

=MAX(0,MIN(KeyDateEnd,$B1)+1-MAX(KeyDateStart,$A1))+1
^^^



  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,420
Default Help need formula for working out date overlaps

Not all of them, just one I think

=MAX(0,MIN(KeyDateEnd,$B2)-MAX(KeyDateStart,$A2))+1

Is Herbert Seidenberg and liztownsend one and the same?


--
__________________________________
HTH

Bob

"Herbert Seidenberg" wrote in message
...
The problem is that
1/11/08 to 30/11/08
when fully expanded reads:
1/11/08 12:00 AM to 30/11/08 12:00 AM
What we really want is:
1/11/08 00:00 to 30/11/08 24:00
which shortens to:
1/11/08 to 1/12/08
If we correct all the end dates this way and
remove all the +1's in Bob's formula, everything works.
Ron's formula now fails and it has problems
if we include odd times.



  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,420
Default Help need formula for working out date overlaps

Ron's is an array formula, but why use an array formula when you can do it
without.

--
__________________________________
HTH

Bob

"smartin" wrote in message
...
smartin wrote:
Herbert Seidenberg wrote:
Try
1/1/2008 20/11/2008
9/11/2008 11/11/2008


Ah, a misplaced paren:

=MAX(0,MIN(KeyDateEnd,$B1)+1-MAX(KeyDateStart,$A1))+1
^^^


If anyone is still looking at this, I wonder if there is an array solution
that will do it? I think such a solution could have much wider
applications that touch on set operations.

E.g., In general, given two series of discreet values, denoted by their
respective endpoints,

series A: a...b
and
series B: c...d

1) Determine how many values are common to A and B, or
2) (better) Enumerate the values common to A and B so they can be counted,
summed, etc.
3) (going a step further) Enumerate the non-intersect values of A and B

Anyone up for a challenge? I know I am--and I dabbled at this, but my
grasp of handling arrays is feeble at best.





  #11   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default Help need formula for working out date overlaps

On Fri, 12 Sep 2008 09:09:46 -0700 (PDT), Herbert Seidenberg
wrote:

The problem is that
1/11/08 to 30/11/08
when fully expanded reads:
1/11/08 12:00 AM to 30/11/08 12:00 AM
What we really want is:
1/11/08 00:00 to 30/11/08 24:00
which shortens to:
1/11/08 to 1/12/08
If we correct all the end dates this way and
remove all the +1's in Bob's formula, everything works.
Ron's formula now fails and it has problems
if we include odd times.


Herbert,

My formula was not designed to handle anything other than full days, as
requested.

What are the circumstances under which it fails?
--ron
  #12   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default Help need formula for working out date overlaps

On Fri, 12 Sep 2008 18:29:49 +0100, "Bob Phillips"
wrote:

Ron's is an array formula, but why use an array formula when you can do it
without.


Easier for a simple mind like mine to understand?
--ron
  #13   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 915
Default Help need formula for working out date overlaps

Bob Phillips wrote:
I don't think so!


Heh! I must have missed something. Seemed like it worked, but I did not
test using nonzero times in the dates.
  #14   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,420
Default Help need formula for working out date overlaps

I think your mind is far from simple Ron

--
__________________________________
HTH

Bob

"Ron Rosenfeld" wrote in message
...
On Fri, 12 Sep 2008 18:29:49 +0100, "Bob Phillips"
wrote:

Ron's is an array formula, but why use an array formula when you can do it
without.


Easier for a simple mind like mine to understand?
--ron



  #15   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default Help need formula for working out date overlaps

On Sat, 13 Sep 2008 10:22:04 +0100, "Bob Phillips"
wrote:

I think your mind is far from simple Ron

--


Thank you.

I guess what I'm really trying to say is that different people think in
different ways. For me, in this kind of problem, it's easy for me to think in
terms of arrays. And even if it is not the most efficient algorithm for
solving the problem, unless the database is very large, it will likely be "good
enough" for now.

Your solution will certainly run faster, and will also not run into the dreaded
"5 Jun 2079" problem in pre-2007 versions, as would my solution :-))
--ron


  #16   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,420
Default Help need formula for working out date overlaps

It was just a statement of fact by someone who reads your responses as a
matter of course because I know they will be enlightening. And my initial
comment wasn't meant as criticism of your formula, but more as extra
information for someone who joined in suggesting that an array formula might
do it, but didn't actually offer one.

As for 2079, I don't know about you, but I think it is beyond my realm of
needing to worry about <bg

--
__________________________________
HTH

Bob

"Ron Rosenfeld" wrote in message
...
On Sat, 13 Sep 2008 10:22:04 +0100, "Bob Phillips"
wrote:

I think your mind is far from simple Ron

--


Thank you.

I guess what I'm really trying to say is that different people think in
different ways. For me, in this kind of problem, it's easy for me to
think in
terms of arrays. And even if it is not the most efficient algorithm for
solving the problem, unless the database is very large, it will likely be
"good
enough" for now.

Your solution will certainly run faster, and will also not run into the
dreaded
"5 Jun 2079" problem in pre-2007 versions, as would my solution :-))
--ron



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculation Total Time With Dates/Times That Overlaps Steve Gilley Excel Discussion (Misc queries) 4 February 18th 08 03:50 PM
Date in Formula not working Dana Excel Discussion (Misc queries) 12 February 28th 06 03:54 PM
Plotting Bands for Task Overlaps gtslabs Charts and Charting in Excel 1 December 5th 05 01:38 AM
Printing in Excel overlaps previous text Nash Excel Discussion (Misc queries) 2 November 8th 05 03:42 PM
Identifying Date Overlaps Tremain Excel Discussion (Misc queries) 1 May 10th 05 01:58 AM


All times are GMT +1. The time now is 12:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"