Difference in date

vmjan02

Well-known Member
Joined
Aug 15, 2012
Messages
1,134
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
I have this records below

If the “PROJECT_NUMBER” is repeated AND “INCIDENT_CREATION_DATE” between the two incidents is less than 31 days then mark it as a "repeat"

I am confused as how shall I do it, as did countif as well to find the duplicate and then the diff in date but the records can be in any row.

[TABLE="width: 500"]
<tbody>[TR]
[TD]INCIDENT_ID[/TD]
[TD]INCIDENT_CREATION_DATE[/TD]
[TD]PROJECT_NUMBER[/TD]
[TD]Result[/TD]
[/TR]
[TR]
[TD]136672962[/TD]
[TD]02-11-2019 09:51:01[/TD]
[TD]112298608[/TD]
[TD]Repeat[/TD]
[/TR]
[TR]
[TD]136672522[/TD]
[TD]02-11-2019 09:51:01[/TD]
[TD]112298601[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]136672581[/TD]
[TD]02-11-2019 09:51:01[/TD]
[TD]112298602[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]136672969[/TD]
[TD]02-12-2019 09:51:01[/TD]
[TD]112298608[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]136672991[/TD]
[TD]02-10-2019 09:51:01[/TD]
[TD]112298690[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]136672999[/TD]
[TD]02-11-2019 09:51:01[/TD]
[TD]112298661[/TD]
[TD]Repeat[/TD]
[/TR]
[TR]
[TD]136672810[/TD]
[TD]02-11-2019 09:51:01[/TD]
[TD]112298685[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1366721010[/TD]
[TD]02-15-2019 09:51:01[/TD]
[TD]112298661[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Change the $20 to whatever is your maximum row.

ABCD
INCIDENT_IDINCIDENT_CREATION_DATEPROJECT_NUMBERResult
Repeat
Repeat

<colgroup><col style="width: 25pxpx"><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="align: center"]2[/TD]
[TD="align: right"]136672962[/TD]
[TD="align: right"]2/11/2019 9:51[/TD]
[TD="align: right"]112298608[/TD]

[TD="align: center"]3[/TD]
[TD="align: right"]136672522[/TD]
[TD="align: right"]2/11/2019 9:51[/TD]
[TD="align: right"]112298601[/TD]

[TD="align: center"]4[/TD]
[TD="align: right"]136672581[/TD]
[TD="align: right"]2/11/2019 9:51[/TD]
[TD="align: right"]112298602[/TD]

[TD="align: center"]5[/TD]
[TD="align: right"]136672969[/TD]
[TD="align: right"]2/12/2019 9:51[/TD]
[TD="align: right"]112298608[/TD]

[TD="align: center"]6[/TD]
[TD="align: right"]136672991[/TD]
[TD="align: right"]2/10/2019 9:51[/TD]
[TD="align: right"]112298690[/TD]

[TD="align: center"]7[/TD]
[TD="align: right"]136672999[/TD]
[TD="align: right"]2/11/2019 9:51[/TD]
[TD="align: right"]112298661[/TD]

[TD="align: center"]8[/TD]
[TD="align: right"]136672810[/TD]
[TD="align: right"]2/11/2019 9:51[/TD]
[TD="align: right"]112298685[/TD]

[TD="align: center"]9[/TD]
[TD="align: right"]1366721010[/TD]
[TD="align: right"]2/15/2019 9:51[/TD]
[TD="align: right"]112298661[/TD]

</tbody>
Sheet1

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]D2
to
Dnnn
[/TH]
[TD="align: left"]=IF(COUNTIF($C3:$C$20,C2)<1,"",IF(ABS(B2-INDEX($B3:$B$20,MATCH(C2,$C3:$C$20,0)))<31,"Repeat",""))[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Change the $20 to whatever is your maximum row.

ABCD
INCIDENT_IDINCIDENT_CREATION_DATEPROJECT_NUMBERResult
Repeat
Repeat

<tbody>
[TD="align: center"]1[/TD]

[TD="align: center"]2[/TD]
[TD="align: right"]136672962[/TD]
[TD="align: right"]2/11/2019 9:51[/TD]
[TD="align: right"]112298608[/TD]

[TD="align: center"]3[/TD]
[TD="align: right"]136672522[/TD]
[TD="align: right"]2/11/2019 9:51[/TD]
[TD="align: right"]112298601[/TD]

[TD="align: center"]4[/TD]
[TD="align: right"]136672581[/TD]
[TD="align: right"]2/11/2019 9:51[/TD]
[TD="align: right"]112298602[/TD]

[TD="align: center"]5[/TD]
[TD="align: right"]136672969[/TD]
[TD="align: right"]2/12/2019 9:51[/TD]
[TD="align: right"]112298608[/TD]

[TD="align: center"]6[/TD]
[TD="align: right"]136672991[/TD]
[TD="align: right"]2/10/2019 9:51[/TD]
[TD="align: right"]112298690[/TD]

[TD="align: center"]7[/TD]
[TD="align: right"]136672999[/TD]
[TD="align: right"]2/11/2019 9:51[/TD]
[TD="align: right"]112298661[/TD]

[TD="align: center"]8[/TD]
[TD="align: right"]136672810[/TD]
[TD="align: right"]2/11/2019 9:51[/TD]
[TD="align: right"]112298685[/TD]

[TD="align: center"]9[/TD]
[TD="align: right"]1366721010[/TD]
[TD="align: right"]2/15/2019 9:51[/TD]
[TD="align: right"]112298661[/TD]

</tbody>
Sheet1

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<tbody>[TR]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH]D2
to
Dnnn[/TH]
[TD="align: left"]=IF(COUNTIF($C3:$C$20,C2)<1,"",IF(ABS(B2-INDEX($B3:$B$20,MATCH(C2,$C3:$C$20,0)))<31,"Repeat",""))[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]

It is working all correct.. Thanks
 
Upvote 0

Similar threads

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top