We have a requirement to build the DateRange (DateRange1) out of chosen Start dateTime and EndDateTime for a resource reservation and identify if another DateRange (DateRange2) is overlapping/subset of that DateRange.
Just an example to add some clarity:
Resource A is reserved between 05/18/08 04:00 PM - 05/19/08 03:00 PM.
Someone else is trying to reserve the same resource between 05/18/08 01:00 PM - 05/19/08 02:00 PM.
Then we should prompt the user with Resource A’s unavailability timeframe (i.e: between 05/18/08 04:00 PM - 05/19/08 02:00 PM)
As such, can we identify if the DateRange1 is subset of/overlapping with DateRange2 and if so, can we seperate the overlap as explanied above.
Hope I made the question clear enough!
BTW, its a Notes client based application…if it makes any difference!
Any help in this regard will be greatly appreciated.
Thanks.
Subject: Identify subset of a Notes DateRange
I don’t know if I got your point well but I guess you should create a ‘Reserve view’ and so place some code at your ‘Reserve’ button to get from that view the documents by key ‘DateRange1’ and check whether the data retrieved is >= yours. On Else checks if ‘DateRange2’ is <= the data retrieved in the second column. You can use @DbLookUp or you can do this with NotesViewEntry or even directly upon the field from the documents you’re looping.
Hope this helps.
Subject: Identify subset of a Notes DateRange
Given two date ranges, StoredRange and QueryRange:
If (QueryRange.EndDateTime.LSLocalTime >= StoredRange.StartDateTime.LSLocalTime) Then
If (QueryRange.StartDateTime.LSLocalTime <= StoredRange.EndDateTime.LSLocalTime) Then
'an overlap exists
End If
End If
Subject: RE: Identify subset of a Notes DateRange
Thanks for your quick responses Gabriel and Stan.
I did some search on similar topics in this forum and found few posts relevant to my requirements. I came across Stan’s responses to one of those posts back in 04.
I am looking into the code given in this response too.
http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/caca4c56aab730e985257068002cb90a?OpenDocument
I assume using your suggestion and the above code, I can identify if an overlap exists. But, is there a way I can identify the extent of overlap so that we can prompt the user about that too.