+ Reply to Thread
Results 1 to 12 of 12

TIME between two dates - want to return blank if empty and use today if end date is empty

  1. #1
    Registered User
    Join Date
    05-22-2020
    Location
    Dublin Ireland
    MS-Off Ver
    2017
    Posts
    25

    TIME between two dates - want to return blank if empty and use today if end date is empty

    Hi

    I have a sheet where i need to calculate the time between a job start date and end date. If the end date isnt entered yet i want it to use todays date as the end date, and i want it to return blanks where neither start date or end date have yet been entered.

    =IF(OR(ISBLANK(H4),ISBLANK(G4)),"",DATEDIF(G4,H4,"M")&"M "&DATEDIF(G4,H4,"MD")&"D")

    G is the start date and H the end date. I have it returning in months and days.

    Thanks to anyone who has a look at this - I find getting excel to return blanks the hardest thing!!

    Thanks in Advance

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,726

    Re: TIME between two dates - want to return blank if empty and use today if end date is em

    You can do it like this:

    =IF(H4&G4="","",DATEDIF(G4,IF(H4="",TODAY(),H4),"M")&"M "&DATEDIF(G4,IF(H4="",TODAY(),H4),"MD")&"D")

    Hope this helps.

    Pete

  3. #3
    Valued Forum Contributor
    Join Date
    03-24-2020
    Location
    Thailand
    MS-Off Ver
    Office 2016
    Posts
    897

    Re: TIME between two dates - want to return blank if empty and use today if end date is em

    Try: =IF(OR(G4="",AND(ISBLANK(H4),ISBLANK(G4))),"",IF(H4="",DATEDIF(G4,TODAY(),"M")&"M "&DATEDIF(G4,TODAY(),"MD")&"D",DATEDIF(G4,H4,"M")&"M "&DATEDIF(G4,H4,"MD")&"D"))

  4. #4
    Valued Forum Contributor
    Join Date
    03-24-2020
    Location
    Thailand
    MS-Off Ver
    Office 2016
    Posts
    897

    Re: TIME between two dates - want to return blank if empty and use today if end date is em

    Slight modification to Pete's formula (which is much neater) so it will return blank if no start date is entered.

    =IF(OR(G4="",H4&G4=""),"",DATEDIF(G4,IF(H4="",TODAY(),H4),"M")&"M "&DATEDIF(G4,IF(H4="",TODAY(),H4),"MD")&"D")

  5. #5
    Registered User
    Join Date
    05-22-2020
    Location
    Dublin Ireland
    MS-Off Ver
    2017
    Posts
    25

    Re: TIME between two dates - want to return blank if empty and use today if end date is em

    Thanks for that I really appreciate it. But the formula is still returning an error message when the end date is missing?

  6. #6
    Valued Forum Contributor
    Join Date
    03-24-2020
    Location
    Thailand
    MS-Off Ver
    Office 2016
    Posts
    897

    Re: TIME between two dates - want to return blank if empty and use today if end date is em

    What error message do you get?
    When the end date is missing the formula is using today's date and showing the date dif in M & D
    Attached Images Attached Images
    Last edited by ORoos; 06-16-2020 at 09:10 AM. Reason: Adding screenshot

  7. #7
    Registered User
    Join Date
    05-22-2020
    Location
    Dublin Ireland
    MS-Off Ver
    2017
    Posts
    25

    Re: TIME between two dates - want to return blank if empty and use today if end date is em

    where the end date is missing i get a #NUM! error - thanks ORoos

  8. #8
    Valued Forum Contributor
    Join Date
    03-24-2020
    Location
    Thailand
    MS-Off Ver
    Office 2016
    Posts
    897

    Re: TIME between two dates - want to return blank if empty and use today if end date is em

    This could be if the start date is greater than the end date. If you leave the end date blank and the start date is in the future, then you get the #NUM error.

  9. #9
    Registered User
    Join Date
    05-22-2020
    Location
    Dublin Ireland
    MS-Off Ver
    2017
    Posts
    25

    Re: TIME between two dates - want to return blank if empty and use today if end date is em

    Hi ORoos

    I have checked that and the start dates are in 2019 so it definately not that. The ones with an end date are returning perfectly - its just the ones missing end dates.

  10. #10
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,726

    Re: TIME between two dates - want to return blank if empty and use today if end date is em

    Please attach a sample workbook showing the errors. The procedure for doing this is given in the yellow banner heading above.

    Pete

  11. #11
    Registered User
    Join Date
    05-22-2020
    Location
    Dublin Ireland
    MS-Off Ver
    2017
    Posts
    25

    Re: TIME between two dates - want to return blank if empty and use today if end date is em

    Hi Pete and ORoss = I put it in to a fresh spreadsheet to upload a sample and it worked! So i think there is an issue with my test spreadsheet.

    Thanks every so much - you guys are great!!

  12. #12
    Valued Forum Contributor
    Join Date
    03-24-2020
    Location
    Thailand
    MS-Off Ver
    Office 2016
    Posts
    897

    Re: TIME between two dates - want to return blank if empty and use today if end date is em

    HiDrOC10,
    Glad to hear all if fine now.
    If all is working now, please mark the thread as SOLVED.

+ 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. [SOLVED] Formula to return empty string instead of null when column table is empty
    By jaryszek in forum Excel Formulas & Functions
    Replies: 26
    Last Post: 02-14-2020, 06:37 AM
  2. [SOLVED] Inserting today's date if cell is empty
    By financeVP in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-01-2019, 12:10 PM
  3. [SOLVED] Add today's Date in next empty cell
    By majime01 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-01-2018, 04:29 PM
  4. [SOLVED] help! Date formula to Return blank if cell is empty
    By marquint in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 01-08-2014, 01:32 AM
  5. Date formula to Return blank if cell is empty
    By Ctaxes in forum Excel - New Users/Basics
    Replies: 9
    Last Post: 01-07-2014, 11:28 PM
  6. Replies: 5
    Last Post: 01-12-2013, 12:16 AM
  7. Replies: 2
    Last Post: 04-11-2012, 02:06 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