Skip to main content
Question

How to compare date ranges?

  • September 10, 2020
  • 4 replies
  • 143 views

Hi all,

 

I have a data set with a start_date column and an end_date column. What I need to do is determine which date ranges overlap, similar to this:

 

https://www.get-digital-help.com/find-overlapping-date-ranges-in-excel/" alt="http://https://www.get-digital-help.com/find-overlapping-date-ranges-in-excel/" target="_blank">https://www.get-digital-help.com/find-overlapping-date-ranges-in-excel/

 

I am fairly new to FME so I apologise in advance!

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

4 replies

ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3422 replies
  • September 10, 2020

I would probably do this spatially. Convert the dates to seconds, then create lines from start to end date, then check for spatial overlaps. I've attached a quick example

 


  • Author
  • 1 reply
  • September 11, 2020

I would probably do this spatially. Convert the dates to seconds, then create lines from start to end date, then check for spatial overlaps. I've attached a quick example

 

Great, many thanks for this!


takashi
Celebrity
  • 7843 replies
  • September 12, 2020

Here is another approach with an InlineQuerier.inlinequerier-parameters

SQL Query

select
    a.*,
    case
        when 0 < count(b.Name) then 'TRUE'
        else 'FALSE'
    end as Overlapping
from source as a
left outer join source as b
on b.Name <> a.Name and b.start <= a.end and a.start <= b.end
group by a.Name

 


  • 1 reply
  • June 15, 2021

Here is another approach with an InlineQuerier.inlinequerier-parameters

SQL Query

select
    a.*,
    case
        when 0 < count(b.Name) then 'TRUE'
        else 'FALSE'
    end as Overlapping
from source as a
left outer join source as b
on b.Name <> a.Name and b.start <= a.end and a.start <= b.end
group by a.Name

 

Hi Takashi,

Thanks for sharing this method - works for me, but partially. Is it possible to define pairs of overlapped records by time periods in output? I presume this should be additional join in query. I need this for further spatial analysis to see if these pairs or maybe there will be more overlapped records intersects with each other spatially. 

 

Thank you in advance!