function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vijaya Bhaskar Rao BattinaVijaya Bhaskar Rao Battina 

Overlapping Dates : Apex

Hi All

I'm new to Apex and Need your help in getting the logic for below:

We have a list(L1) of custom object(DataValues with fields Start_Date,End_date, unit).
I beign to insert Data into the list(L1) and my logic should be incorporated as below:

if the existing data in the List is as below:
Start_date             End_Date , Unit
15-mar-2018 ,   31-mar-2018 , 10 

If I insert into list(L1)with data , [18-mar-2018 , 21-mar-2018 , 15] ; my new data in the List should be:
Start_date             End_Date , Unit
15-mar-2018 ,   18-mar-2018 , 10 
18-mar-2018 , 21-mar-2018 , 15
22-mar-2018 , 31-mar-2018 , 10

If I now add to the list the date [14-mar-2018 , 19-mar-2018, 12]; my new data in the List should be :
Start_date             End_Date , Unit
14-mar-2018 ,   19-mar-2018 , 12
20-mar-2018 , 21-mar-2018 , 15
22-mar-2018 , 31-mar-2018 , 10

If I now add to the list the date [14-mar-2018 , 19-mar-2018, 18]; my new data in the List should be :
Start_date             End_Date , Unit
14-mar-2018 ,   19-mar-2018 , 18
20-mar-2018 , 21-mar-2018 , 15
22-mar-2018 , 31-mar-2018 , 10

If I now add to the list the date [13-mar-2018 , 23-mar-2018, 26]; my new data in the List should be :
Start_date             End_Date , Unit
13-mar-2018 ,   23-mar-2018 , 26
24-mar-2018 , 31-mar-2018 , 10

So the list should get updated based on the new entry added.
Requesting your support.
 
Vijaya Bhaskar Rao BattinaVijaya Bhaskar Rao Battina
Some one ... Some Help on this Please