+ Reply to Thread
Results 1 to 14 of 14

Using DATEDIF, to produce a negative Y/M/D

  1. #1
    Registered User
    Join Date
    05-08-2013
    Location
    Utah
    MS-Off Ver
    Office 365
    Posts
    30

    Using DATEDIF, to produce a negative Y/M/D

    Hi All,

    I'm trying to make an excel to keep track of those in my family and birthdays. I'm also trying for each member, to compare it to my birthday and have it display in Years Months Days the difference. Works great for those younger than me using this formula:

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


    Whereas F2 is my birthday and F4, F5, F6 etc are my family members' birthdays.


    My issue is when they are older than me. I want it to display a negative years etc: - 1 year 9 months 2 days as an example.

    It's just now showing a #NUM! error.

    Is there a way to correct this or make it work in the way I want? Or is another formula needed?

    Thanks so much.

  2. #2
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070

    Re: Using DATEDIF, to produce a negative Y/M/D

    Hi,

    You could test following :
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    HTH
    Carim


    Top Excel Links

  3. #3
    Registered User
    Join Date
    05-08-2013
    Location
    Utah
    MS-Off Ver
    Office 365
    Posts
    30

    Re: Using DATEDIF, to produce a negative Y/M/D

    Quote Originally Posted by Carim View Post
    Hi,

    You could test following :
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    I will give it a shot and report back. Thank you!

  4. #4
    Registered User
    Join Date
    05-08-2013
    Location
    Utah
    MS-Off Ver
    Office 365
    Posts
    30

    Re: Using DATEDIF, to produce a negative Y/M/D

    Carim,

    That really seemed to work! Thanks!

    One question in regards to the way it displays. I have them as you can see displaying as: - 1 yrs 0 m 1 d *and* 3 yrs 2 m 26 d.

    If I got to sort column, it seems to sort right to a point. However a -1 and a -10 and a 1 and 10 sort to the same area. Is there anyway to fix the display to be essentially:

    XX yrs XX m XX d, to where maybe it'd sort correctly?

    Thanks again so much!

  5. #5
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070

    Re: Using DATEDIF, to produce a negative Y/M/D

    Glad this is helping you out ...

    Regarding the sort issue, not sure to fully understand ... but would recommend to sort the input data (and not the column with your formula)

  6. #6
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Using DATEDIF, to produce a negative Y/M/D

    Your answers as excel does not display negative dates, are being returned as a text string, as such 1s and 10s will be together before 2s. If you just created another column that was one date taken away from the other and formatted as a number. this would give you the number of days, sorting by this would probably put the data in the order you desire. If it is just the difference use ABS. this would also probably work just by sorting by the other persons DOB

    $F$2-F4

    or

    ABS($F$2-F4) for the absolute difference

  7. #7
    Registered User
    Join Date
    05-08-2013
    Location
    Utah
    MS-Off Ver
    Office 365
    Posts
    30

    Re: Using DATEDIF, to produce a negative Y/M/D

    Sorting the Birthdate indeed did work! Brainfart there missing that.

    As for the display of the difference's, I was wondering if there was a way to force it to display as such:

    ## yrs, ## m, ## d

    Thanks for all your help!!!

  8. #8
    Registered User
    Join Date
    05-08-2013
    Location
    Utah
    MS-Off Ver
    Office 365
    Posts
    30

    Re: Using DATEDIF, to produce a negative Y/M/D

    You're right. As for now this works great for what I need, minus maybe the thing I replied saying I wish I could get the DATED if to display as such:

    ## yrs, ## m, ## d

    As for what Carim said, and you. Indeed, my issue can easily be done by just sorry the birthday's column.

    Thanks so much for your reply!

  9. #9
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Using DATEDIF, to produce a negative Y/M/D

    if you mean everything is 2 digits, altering each bit to put it inside a text function forcing 2 digits may be what you want


    TEXT(DATEDIF($F$2,F4,"y"),"00") &" Yrs" etc etc etc

  10. #10
    Registered User
    Join Date
    05-08-2013
    Location
    Utah
    MS-Off Ver
    Office 365
    Posts
    30

    Re: Using DATEDIF, to produce a negative Y/M/D

    That works great! Thanks Davsth!

    Was curious if there's a way to make the years show Positive (+) in front. I see how the ( - ) is implemented, but not sure where to put the " + ".
    Last edited by FlyinIron406; 01-08-2021 at 09:54 PM.

  11. #11
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Using DATEDIF, to produce a negative Y/M/D

    something like, and there are probably better ways

    if($F$2>F4,"+","") & the rest of your formula as it currently exists


    is that what you mean?

  12. #12
    Registered User
    Join Date
    05-08-2013
    Location
    Utah
    MS-Off Ver
    Office 365
    Posts
    30
    Quote Originally Posted by davsth View Post
    something like, and there are probably better ways

    if($F$2>F4,"+","") & the rest of your formula as it currently exists


    is that what you mean?
    I’ll give That a shot and reply back!

  13. #13
    Registered User
    Join Date
    05-08-2013
    Location
    Utah
    MS-Off Ver
    Office 365
    Posts
    30

    Re: Using DATEDIF, to produce a negative Y/M/D

    Quote Originally Posted by davsth View Post
    something like, and there are probably better ways

    if($F$2>F4,"+","") & the rest of your formula as it currently exists


    is that what you mean?
    Hey Davsth,

    I tried that as you suggested and I get "too many arguments for this function". Here's the whole formula and maybe that'll help.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by FlyinIron406; 01-11-2021 at 10:13 PM.

  14. #14
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Using DATEDIF, to produce a negative Y/M/D

    Please Login or Register  to view this content.


    or am I missing something, you don't even need the if

+ 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. Want IF statement to produce 0 if the formula result is negative
    By ExcelNoobie1 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-12-2019, 10:52 AM
  2. [SOLVED] DATEDIF - DATEDIF Calculation returning a negative for days or months
    By DaveBre in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-27-2015, 06:22 PM
  3. Replies: 3
    Last Post: 07-16-2014, 01:50 AM
  4. Negative Datedif
    By mattsgr1 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-22-2013, 03:42 PM
  5. Replies: 3
    Last Post: 07-02-2012, 06:02 AM
  6. [SOLVED] Negative return in =DATEDIF function
    By Steve in forum Excel General
    Replies: 4
    Last Post: 03-02-2006, 02:25 PM
  7. Why "datedif" function results sometimes negative numbers?
    By Ambrosiy in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-08-2005, 07:05 AM

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