Q:

Find time difference between two columns based on unique id and add the absence days

I am stuck on a problem where i want to find out the absent days for an employee where if he is not coming for 3 consecutive days it should add the 3 days in a new column (it might for for multiple days) the problem is start date and end date is there so i want to match if the employee is same, start date of the next absence is consecutive day it should add it , i am attaching the screenshot and table index here . Any help from Excel or R will be helpful. I have already tried Max if and Sumif. Only problem is I only want addition if he/she is absent for the consecutive days
ID  START_DATE  END_DATE    ABSENCE_DAYS
3   14-06-18    14-06-18    1
3   17-06-18    17-06-18    1
3   18-06-18    18-06-18    1
4   01-06-18    01-06-18    1
4   04-06-18    04-06-18    1
4   21-06-18    22-06-18    2
4   27-06-18    27-06-18    1
4   28-06-18    28-06-18    1
4   04-07-18    04-07-18    1
4   05-07-18    05-07-18    1
4   09-07-18    09-07-18    1
4   11-07-18    11-07-18    1
4   23-07-18    23-07-18    1
4   24-07-18    24-07-18    1
4   25-07-18    25-07-18    1
5   07-06-18    08-06-18    2
5   28-06-18    28-06-18    1
5   27-07-18    27-07-18    0.5
6   10-06-18    11-06-18    2
6   17-06-18    21-06-18    5
6   24-06-18    25-06-18    2
6   26-06-18    03-07-18    6
6   15-07-18    15-07-18    1
6   22-07-18    22-07-18    1

For Example Employee 4 has taken 3 consecutive leaves on 23,24 and 25th so in a new column where it says he was absent for 3 consecutive days.

updated
Desired output would look something like this , this is just a sample

A:

Here is a solution using data.table. You can check if the START_DATE of current row is one day after the END_DATE of the previous row and use cumsum to group these together. After that, it is just a simple sum of ABSENCE_DAYS once you can group them properly.
welfare[, TOTAL_ABSENCE := sum(ABSENCE_DAYS), 
    by=.(ID, cumsum(START_DATE != shift(END_DATE, fill=1L) + 1L))]

output:
    ID START_DATE   END_DATE ABSENCE_DAYS TOTAL
 1:  3 2018-06-14 2018-06-14          1.0   1.0
 2:  3 2018-06-17 2018-06-17          1.0   2.0
 3:  3 2018-06-18 2018-06-18          1.0   2.0
 4:  4 2018-06-01 2018-06-01          1.0   1.0
 5:  4 2018-06-04 2018-06-04          1.0   1.0
 6:  4 2018-06-21 2018-06-22          2.0   2.0
 7:  4 2018-06-27 2018-06-27          1.0   2.0
 8:  4 2018-06-28 2018-06-28          1.0   2.0
 9:  4 2018-07-04 2018-07-04          1.0   2.0
10:  4 2018-07-05 2018-07-05          1.0   2.0
11:  4 2018-07-09 2018-07-09          1.0   1.0
12:  4 2018-07-11 2018-07-11          1.0   1.0
13:  4 2018-07-23 2018-07-23          1.0   3.0
14:  4 2018-07-24 2018-07-24          1.0   3.0
15:  4 2018-07-25 2018-07-25          1.0   3.0
16:  5 2018-06-07 2018-06-08          2.0   2.0
17:  5 2018-06-28 2018-06-28          1.0   1.0
18:  5 2018-07-27 2018-07-27          0.5   0.5
19:  6 2018-06-10 2018-06-11          2.0   2.0
20:  6 2018-06-17 2018-06-21          5.0   5.0
21:  6 2018-06-24 2018-06-25          2.0   8.0
22:  6 2018-06-26 2018-07-03          6.0   8.0
23:  6 2018-07-15 2018-07-15          1.0   1.0
24:  6 2018-07-22 2018-07-22          1.0   1.0
    ID START_DATE   END_DATE ABSENCE_DAYS TOTAL

data:
library(data.table)
welfare <- fread(
"ID  START_DATE  END_DATE    ABSENCE_DAYS
3   14-06-18    14-06-18    1
3   17-06-18    17-06-18    1
3   18-06-18    18-06-18    1
4   01-06-18    01-06-18    1
4   04-06-18    04-06-18    1
4   21-06-18    22-06-18    2
4   27-06-18    27-06-18    1
4   28-06-18    28-06-18    1
4   04-07-18    04-07-18    1
4   05-07-18    05-07-18    1
4   09-07-18    09-07-18    1
4   11-07-18    11-07-18    1
4   23-07-18    23-07-18    1
4   24-07-18    24-07-18    1
4   25-07-18    25-07-18    1
5   07-06-18    08-06-18    2
5   28-06-18    28-06-18    1
5   27-07-18    27-07-18    0.5
6   10-06-18    11-06-18    2
6   17-06-18    21-06-18    5
6   24-06-18    25-06-18    2
6   26-06-18    03-07-18    6
6   15-07-18    15-07-18    1
6   22-07-18    22-07-18    1")    
cols <- c("START_DATE", "END_DATE")
welfare[, (cols) := lapply(.SD, as.Date, format="%d-%m-%y"), .SDcols=cols]

