BookmarkSubscribeRSS Feed
Smitha9
Fluorite | Level 6

Hi,

 I have a dataset A:

ID     Car_part        DateA           Check_Date

1         mirror      01/02/2010        04/16/2020

1         Brake      01/03/2010        04/16/2020

1        mirror        01/23/2014       04/16/2020

2       mirror     12/13/2008          04/15/2018

2       mirror      12/13/2008         04/15/2018

2       mirror       12/18/2012       04/15/2018

3    mirror       07/07/2010         08/09/2015

3    Car          07/07/2010         08/09/2015

3    mirror       07/29/2010         09/08/2016

 

I want how many days are in between  DateA and CheckDate.

Also I want to select 2 dates which are earliest near Check_Date.

If there duplicates then delete. But if there are duplicates and Car_Part is  different. Then I want earliest and second earliest the same with different Car_Part.

Want Dataset:

ID     Car_part        DateA           Check_Date     Difference_Days

1        mirror        01/23/2014       04/16/2020 

1         Brake      01/03/2010        04/16/2020

2         mirror       12/18/2012       04/15/2018

2       mirror      12/13/2008         04/15/2018

3        mirror       07/07/2010         08/09/2015          same but car_part is mirror

3        Car          07/07/2010         08/09/2015           same but care_part is car

1 REPLY 1
PaigeMiller
Diamond | Level 26

To determine the number of days between DateA and Check_Date, you just subtract these dates (assuming they are numeric).

 

Since you don't give an example of finding the nearest date and the next nearest date, I request that you change your example, and change your want data set, to illustrate this.

--
Paige Miller