+ Reply to Thread
Results 1 to 15 of 15

Difference between two dates for one unique value thats repeats itself

  1. #1
    Registered User
    Join Date
    03-02-2024
    Location
    UK
    MS-Off Ver
    365
    Posts
    54

    Difference between two dates for one unique value thats repeats itself

    Hello everyone, my goal is a formula if S2 (and following values in S) matches any value in column B, then give me the difference in years and months from T2 and matching cell from column L belong to the matching value in B

    The B column values are all from the same unique ID that have procedures in different dates. The idea is to get years and months since they've joined (column T) in all the different procedures. So say in the example I've done 1111 which joined on the 09/04/2018 is 5y and 8 months on the procedure dated 18/12/2023. It would be 5y and 6 months for the previous procedure on the 18/10/2023

    So each value on S only has one unique date of joining (column T) but have different or equal procedures dates. Do let me know if I didn't explained correctly.

    Do let me know if I haven't explained correctly or if you need any more information

    Thanks!

    Test11.xlsx
    Last edited by ExcelNewbie92; 03-02-2024 at 05:03 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,613

    Re: Difference between two dates for one unique value thats repeats itself

    Fast answers need visual help. Please read the yellow banner at the top of this page on how to attach a file and a mocked up solution.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    03-02-2024
    Location
    UK
    MS-Off Ver
    365
    Posts
    54

    Re: Difference between two dates for one unique value thats repeats itself

    Really sorry TMS! As I wasn't allowed to add the link, thought wouldn't be able to add an attachment. Done now and think it's working

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,430

    Re: Difference between two dates for one unique value thats repeats itself

    Try this in R2 copied down:

    =LET(d,INDEX($L$2:$L$16,MATCH(S2,$B$2:$B$16,0)),IF(ISNA(d),"",DATEDIF(T2,d,"y")&" years, "&DATEDIF(T2,d,"ym")&" months"))

    Not clear which date you want from column L if there are multiples ...

    If the max:

    =LET(d,MAXIFS($L$2:$L$16,$B$2:$B$16,S2),IF(ISNA(d),"",DATEDIF(T2,d,"y")&" years, "&DATEDIF(T2,d,"ym")&" months"))

    If the min:

    =LET(d,MINIFS($L$2:$L$16,$B$2:$B$16,S2),IF(ISNA(d),"",DATEDIF(T2,d,"y")&" years, "&DATEDIF(T2,d,"ym")&" months"))
    Attached Files Attached Files
    Last edited by AliGW; 03-02-2024 at 05:15 AM. Reason: Workbook added.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Registered User
    Join Date
    03-02-2024
    Location
    UK
    MS-Off Ver
    365
    Posts
    54

    Re: Difference between two dates for one unique value thats repeats itself

    Thank you for your reply and time AliGW! You're on to something but perhaps I didn't explained correctly one thing. Column S has unique values of IDs that have joined on that specific date in column T. This gives me a starting date for all the IDs that will show up in column B.

    Column B on the other hand gives me that same IDs, repeating themselves several times but with different dates of procedures. The goal is to have the years and months since that ID joining from that specific procedure.

    R2 = 5y 8 months because B2 (1111) joined on 09/04/2018 (T2)
    R3 = Should equal 5y 6 months because B3 (still 1111) still joined on 09/04/2018 (T2)
    And same until the ID on B changes to a different value

    Perhaps something like vlookup could be added to the formula?

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,430

    Re: Difference between two dates for one unique value thats repeats itself

    Is this what you want?

    AliGW on MS365 Beta Channel (Windows 11) 64 bit

    V
    W
    X
    Y
    1
    1111
    2222
    3333
    4444
    2
    5 years, 6 months 8 years, 7 months 6 years, 8 months 9 years, 11 months
    3
    5 years, 8 months 8 years, 9 months 6 years, 11 months 9 years, 11 months
    4
    9 years, 3 months 7 years, 1 months
    5
    10 years, 4 months 10 years, 3 months
    Sheet: Sheet1

    If not, please mock up in FULL what you want to see in the sample workbook.

  7. #7
    Forum Expert
    Join Date
    10-19-2021
    Location
    Brazil
    MS-Off Ver
    Office 365 V2401 w/ Win10 Home 64 Bit
    Posts
    2,014

    Re: Difference between two dates for one unique value thats repeats itself

    My formula for this.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,430

    Re: Difference between two dates for one unique value thats repeats itself

    Or, in C2 copied down:

    =LET(d,INDEX($T$2:$T$5,MATCH(B2,$S$2:$S$5,0)),IF(ISNA(d),"",DATEDIF(d,L2,"y")&" years, "&DATEDIF(d,L2,"ym")&" months"))

    AliGW on MS365 Beta Channel (Windows 11) 64 bit

    B
    C
    2
    1111
    5 years, 8 months
    3
    1111
    5 years, 6 months
    4
    1111
    5 years, 8 months
    5
    1111
    5 years, 6 months
    6
    2222
    10 years, 4 months
    7
    2222
    9 years, 3 months
    8
    2222
    8 years, 9 months
    9
    2222
    8 years, 7 months
    10
    3333
    7 years, 1 months
    11
    3333
    6 years, 11 months
    12
    3333
    6 years, 8 months
    13
    3333
    10 years, 3 months
    14
    4444
    9 years, 11 months
    15
    4444
    9 years, 11 months
    16
    5555
    Sheet: Sheet1

    Attached Files Attached Files
    Last edited by AliGW; 03-02-2024 at 05:36 AM. Reason: Workbook added.

  9. #9
    Registered User
    Join Date
    03-02-2024
    Location
    UK
    MS-Off Ver
    365
    Posts
    54

    Re: Difference between two dates for one unique value thats repeats itself

    Thank you DJunqueira!! That work perfectly.

    Sorry AliGW, perhaps I didn't explained correctly and next time I will add more manual examples to my mock spreadsheet to be easier for helping. And your second formula seems to have worked as well. Thank you both!

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,430

    Re: Difference between two dates for one unique value thats repeats itself

    Look at post #8 - it does the same is DJ's in a slightly more efficient way.

    Glad to have helped.

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, remember that you can thank anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of each of those who offered help.

  11. #11
    Registered User
    Join Date
    03-02-2024
    Location
    UK
    MS-Off Ver
    365
    Posts
    54

    Re: Difference between two dates for one unique value thats repeats itself

    Thank you, done and done to both of you

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,430

    Re: Difference between two dates for one unique value thats repeats itself

    You're welcome.

    Yes, next time mock up WHAT you waht to see WHERE you want to see it.

  13. #13
    Registered User
    Join Date
    03-02-2024
    Location
    UK
    MS-Off Ver
    365
    Posts
    54

    Re: Difference between two dates for one unique value thats repeats itself

    Will do AliGW, and still in this topic, could you please still help me at another formula, which would give me the max date for every ID? As in:

    Max date for 1111 - 5y 8 months
    Max date for 2222 - 10 years 4 months
    Max date for 3333 - 10 years 3 months
    Last edited by AliGW; 03-02-2024 at 06:30 AM. Reason: Please don't quote unnecessarily - use the Quick Reply button instead.

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,430

    Re: Difference between two dates for one unique value thats repeats itself

    You've already got that in my workbook.

    AliGW on MS365 Beta Channel (Windows 11) 64 bit

    Q
    1
    Max
    2
    5 years, 8 months
    3
    10 years, 4 months
    4
    10 years, 3 months
    5
    9 years, 11 months
    Sheet: Sheet1

  15. #15
    Forum Expert
    Join Date
    10-19-2021
    Location
    Brazil
    MS-Off Ver
    Office 365 V2401 w/ Win10 Home 64 Bit
    Posts
    2,014

    Re: Difference between two dates for one unique value thats repeats itself

    Tks for the feedback, glad to help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 04-08-2023, 05:50 PM
  2. Replies: 2
    Last Post: 07-26-2020, 04:50 PM
  3. Extracting a unique list from cells with a lot of repeats
    By hobofromdowntown in forum Excel General
    Replies: 4
    Last Post: 10-30-2019, 03:27 PM
  4. [SOLVED] How to calculate date difference between two dates with its related unique ID.
    By JayeshG in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-27-2018, 12:55 PM
  5. [SOLVED] Create unique array from columns with multiple repeats
    By BRISBANEBOB in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-16-2017, 09:10 PM
  6. [SOLVED] Column Z difference for repeats
    By Jim Em in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-06-2014, 09:45 AM
  7. Replies: 4
    Last Post: 01-26-2014, 05:48 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1