+ Reply to Thread
Results 1 to 15 of 15

Using IF functions to ignore date/time cells with missing date or time

  1. #1
    Registered User
    Join Date
    03-23-2017
    Location
    Northern Ireland
    MS-Off Ver
    Office 2010
    Posts
    24

    Using IF functions to ignore date/time cells with missing date or time

    I have a table with some date/time cells "DD/MM/YYYY HH:MM". I am using the following formula to ensure that when a date without a time is recorded (A5 in the example below) the system uses the data in Column B instead "=IF(TIME(HOUR(A1),MINUTE(A1),0),A1,B1)"

    This solves the issue with returning #Value! when I am trying to work out the duration's of these jobs (when the time data is missing from the start of the job). I am now looking for a way (as part of the same formula) to take the data in Column B if the data in A does not have a date either (example in A7)? I'm just a little lost on the syntax of such a formula. So for example a call in A contains "DD/MM/YYYY" only or "HH:MM" only i wish to direct it to the same cell in B when displaying the duration times using one formula if that's possible?

    ____________A__________________B
    ____Orig Start DateTime_____Completed DateTime
    1____01/09/2018 18:58____01/09/2018 19:58
    2____01/09/2018 15:50____01/09/2018 15:57
    3____01/09/2018 15:20____01/09/2018 15:26
    4____01/09/2018 13:13____01/09/2018 13:21
    5____01/09/2018_________01/09/2018 01:00
    6____01/09/2018 06:25____01/09/2018 06:28
    7____10:44______________01/09/2018 10:54


    Sorry I just noticed the message about cross posting being discouraged. This was also posted here https://www.mrexcel.com/forum/excel-...ml#post5202977 but that was a few weeks ago to get help with the formula above. Once i realised i need to cover both missing time and missing date i added a comment but i am unsure of the response (or how to integrate it with the existing formula) and the guy is offline. In my panic i have come here.
    Last edited by Custhasno; 01-07-2019 at 10:14 AM. Reason: formatting table and spelling and rules

  2. #2
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Using IF functions to ignore date/time cells with missing date or time

    Perhaps

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

  3. #3
    Registered User
    Join Date
    03-23-2017
    Location
    Northern Ireland
    MS-Off Ver
    Office 2010
    Posts
    24

    Re: Using IF functions to ignore date/time cells with missing date or time

    A very elegant looking solution thanks. it doesn't seem to be picking up the absence of dates in the date/time cell though. It is still showing a #VALUE! for the 7th row (time with no date).
    Last edited by AliGW; 01-07-2019 at 12:13 PM.

  4. #4
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Using IF functions to ignore date/time cells with missing date or time

    Hmm, that is peculiar, if you explicitly coerce?

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


    If the above does not work please try and post a sample file (use GoAdvanced --> Manage Attachments), as that may highlight formatting issues etc....

  5. #5
    Registered User
    Join Date
    03-23-2017
    Location
    Northern Ireland
    MS-Off Ver
    Office 2010
    Posts
    24

    Re: Using IF functions to ignore date/time cells with missing date or time

    Thanks, i have attached an example file. The second formula you included wont sit as a formula when i change the cells and paste it in it shows as text but Im using the = correctly.

    For reference the cells in red are examples of partial data Most are missing the time and one is missing the date, the cells in bold are the formulas that deal with them.
    Attached Files Attached Files
    Last edited by Custhasno; 01-07-2019 at 12:21 PM. Reason: more info

  6. #6
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Using IF functions to ignore date/time cells with missing date or time

    thanks; switched to TRIM

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


    premise for above is that dates are integers, and time decimal (hour being 1/24) -- so above just checks if Integer is 0 (no date), or is devoid of decimal (no time)

  7. #7
    Registered User
    Join Date
    03-23-2017
    Location
    Northern Ireland
    MS-Off Ver
    Office 2010
    Posts
    24

    Re: Using IF functions to ignore date/time cells with missing date or time

    It's all sufficiently advance for me to seem like magic, thank you kindly this works perfectly.

    Edit: When i get a blank cell instead of a partial one is there anyway to get that to also trigger the formula to take the date from another cell instead? They are currently showing as #Value! ?
    Last edited by Custhasno; 01-07-2019 at 12:43 PM.

  8. #8
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Using IF functions to ignore date/time cells with missing date or time

    Hi, apologies for belated reply - away from my machine; would below work for you?

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

  9. #9
    Registered User
    Join Date
    03-23-2017
    Location
    Northern Ireland
    MS-Off Ver
    Office 2010
    Posts
    24
    Quote Originally Posted by XLent View Post
    Hi, apologies for belated reply - away from my machine; would below work for you?

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    I away from my machine now until tomorrow but thanks in advance

    Edit: This works perfectly, thank you soo much.
    Last edited by Custhasno; 01-08-2019 at 05:21 AM. Reason: Solved

  10. #10
    Registered User
    Join Date
    03-23-2017
    Location
    Northern Ireland
    MS-Off Ver
    Office 2010
    Posts
    24

    Re: Using IF functions to ignore date/time cells with missing date or time

    The help so far has been excellent, unfortunately I need to ask for a little bit more help if possible?

    Is there anyway the formula could also ignore both cells if they are blank and go to a 3rd row instead? I am now left with date/time of 00/01/1900 for any cells i apply this formula to if both are blank

  11. #11
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Using IF functions to ignore date/time cells with missing date or time

    Third row, or third cell?

    In short, yes, you could have an IF around G2 however, if you could provide specifics we can tailor to your exact requirement(s) -- there may be a more elegant solution available that would iterate a range to find last valid datetime etc.

  12. #12
    Registered User
    Join Date
    03-23-2017
    Location
    Northern Ireland
    MS-Off Ver
    Office 2010
    Posts
    24

    Re: Using IF functions to ignore date/time cells with missing date or time

    Quote Originally Posted by XLent View Post
    Third row, or third cell?

    In short, yes, you could have an IF around G2 however, if you could provide specifics we can tailor to your exact requirement(s) -- there may be a more elegant solution available that would iterate a range to find last valid datetime etc.
    Thanks, ill try my best, could you give me an example with the IF G included, I'm ok once i have one to reverse engineer lol.

    The file is that cumbersome I'm not even sure how to get just the relevant info for a simple file.

    The data is essentially the time info for all repair jobs entered on to our system by our users. We have times for "job entered", "requested time", "Time started" and "Time completed" for any job we are asked to carry out across a large site. Because we are a 24/7 service we have kept date/time data combined "DD/MM/YYYY HH:MM" to allow for working out of durations when the jobs goes over in to the next day.

    The next issue was that some rows where missing one or more of those pieces of data so some cells had only times HH:MM and other had only dates DD/MM/YYYY. The solution was to go to the next time, so if there was no allocation time recorded we take the allocation time as the start time of the jobs instead.

    The final piece of the puzzle is to try to cope with the rarer occurrence of both cells in the formula being blank. IN that scenario i would like to point it to another cell (next row over)

    The big sticking point is i have no control over the raw data i get, its outputted automatically and I am trying to build a reporting template in to which i can simply dump the raw data and have these formulas deal with any scenario of partial or missing data in this is hopefully the last piece of the puzzle.

  13. #13
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Using IF functions to ignore date/time cells with missing date or time

    Assuming you don't need to validate G in the same way you do F (i.e. will always be either blank or legitimate value and never time only etc) then

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

    However, if you need to apply similar logic against G as F, and potentially the "alternate" (should it be invoked) you would need to adjust the above. Again, this can be done, but it would be good to know what the alternate logic will be, whether it requires pre-emptive validation, and whether or not the "iterations" should continue until such time as a valid value is found.

  14. #14
    Registered User
    Join Date
    03-23-2017
    Location
    Northern Ireland
    MS-Off Ver
    Office 2010
    Posts
    24

    Re: Using IF functions to ignore date/time cells with missing date or time

    Thanks i am trying that now.

    So to try to explain better i need the formula to spot when a date/time is not correct and then use the next available date/time one row over for working out the durations at each stage.
    So jobs go in the following order
    Entered Time- when they are put on the system by a user
    Requested time - Set to same time as entered unless changed to a future time by the user
    Allocated time - when the job is sent to a workers handheld
    Start - When that worker accepts/starts the jobs
    Finish - When a worker completes the job

    So if for example the system didn't capture the allocation time, i want the formula to take the start time (provided its not blank) and use that as the allocation time. The columns with this info are not all in a row.

  15. #15
    Registered User
    Join Date
    03-23-2017
    Location
    Northern Ireland
    MS-Off Ver
    Office 2010
    Posts
    24

    Re: Using IF functions to ignore date/time cells with missing date or time

    This is working perfectly now i can't thank you enough

+ 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] Calculating Elapse time from Dates with one date missing
    By david2020 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-15-2017, 06:27 AM
  2. [SOLVED] My date/Time conundrum or am I missing a simple trick?
    By Missus Mommabear in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-28-2015, 07:38 AM
  3. Replies: 9
    Last Post: 02-15-2015, 07:32 PM
  4. Replies: 3
    Last Post: 12-19-2013, 06:49 AM
  5. Add missing Time in cells with a date
    By rdawes26 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-22-2013, 01:29 PM
  6. Replies: 2
    Last Post: 04-10-2013, 11:17 AM
  7. Calculating days & time left from start date/time to end date/time
    By marie in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-07-2005, 10:40 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