+ Reply to Thread
Results 1 to 6 of 6

4 working hours before a date and time

  1. #1
    Registered User
    Join Date
    11-20-2023
    Location
    London, England
    MS-Off Ver
    MS365 2312
    Posts
    3

    Lightbulb 4 working hours before a date and time

    Hello!

    I'm trying to work out a formula that will tell me what time it was 4 working hours ago, I've asked ChatGpt (I know, sorry) for some help and it is only giving me formula's that will tell me 4 hours (not working hours) and it doesn't seem to understand what working hours are (at least I'm not out of a job...) ANYWAY

    The date and time it needs to look at is in cell AC1 and it is in a dd/mm/yyyy hh:ss format. The formula is needed so I can work out whether an email is within our 4 working hour turn around time.
    Working hours are
    Monday - Friday: 9am - 6:30pm
    Saturday: 9am - 4pm
    Sunday: Closed

    It keeps giving me this formula =IF(OR(WEEKDAY(AC1,2)>5,HOUR(AC1)<9,HOUR(AC1)+MINUTE(AC1)/60>=18.5), WORKDAY(AC1,-1)+TIME(18,30,0), IF(HOUR(AC1)-4/24<9, WORKDAY(AC1,-1)+TIME(18,30,0), AC1-TIME(4,0,0))) but say the date and time displayed was 11/01/2024 07:16 (using the =NOW() formula) that returns 18:30 which is not right. All others just give the complete wrong date and time.

    Between 10/01/2024 18:30 to 11/01/2024 09:00 the 4 working hour timer should essentially stop because that is outside of working hours.
    Attached Files Attached Files
    Last edited by lottiee; 01-11-2024 at 04:01 AM. Reason: adding example document

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,917

    Re: 4 working hours before a date and time

    Administrative Note:

    Welcome to the forum.

    Is your forum profile showing the Excel PRODUCT that you need this to work for?

    Members will tailor the solutions they offer to the Office PRODUCT (Excel, NOT Windows) that you have. Please check that your forum profile is up-to-date in this respect. If you aren't sure, in Excel go to File | Account and report what it says below the MS logo at the top of that page. If your product is for Mac, please also state this.

    The three most recent Excel products are Excel 2019, Excel 2021 and MS365 - if you are using MS365, please give this name along with the version number in your profile (e.g. MS365 Version 2306). This is in the About Excel section further down the Account page.

    Thanks.
    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. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    11-20-2023
    Location
    London, England
    MS-Off Ver
    MS365 2312
    Posts
    3

    Re: 4 working hours before a date and time

    Thank you - changed the "My Microsoft Office Version" to MS365 2312

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

    Re: 4 working hours before a date and time

    Please provide a sample workbook with a few manually calculated examples.

  5. #5
    Registered User
    Join Date
    11-20-2023
    Location
    London, England
    MS-Off Ver
    MS365 2312
    Posts
    3

    Re: 4 working hours before a date and time

    Done - don't know how to add it to another post,

    Column A = the dates and times emails have been received
    C2 = would normally show the =NOW() formula, but just so the time doesn't keep changing have fixed this to 7:30am
    D2 = would normally show the working hours formula, but I've changed this to a fixed time so that the conditional formatting works
    E2 = wouldn't normally be there - that's just putting the formula in there for now so it can be seen how it's wrong
    Last edited by lottiee; 01-11-2024 at 04:10 AM.

  6. #6
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,980

    Re: 4 working hours before a date and time

    Finding a solution to a problem like this usually requires many examples that cover the range of possible scenarios.
    For the one example given the formula could be:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Note that K2 and K3 contain the start and end times for weekdays.
    Let us know if you have any questions.
    Last edited by JeteMc; 01-13-2024 at 12:01 PM. Reason: Updated formula
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ 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: 11-11-2019, 10:04 AM
  2. Add working hours only to a date and time
    By AllanWilliams in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-01-2015, 07:46 AM
  3. Replies: 1
    Last Post: 06-05-2015, 06:57 AM
  4. Replies: 3
    Last Post: 05-14-2015, 07:32 AM
  5. next due date and time with in working hours
    By kiranrk2lv in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-14-2014, 05:25 AM
  6. [SOLVED] Calculate time for working hours when start time falls outside of working hours
    By SKDY_Beau in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-20-2014, 12:50 PM
  7. Adding Working Hours To Date / Time
    By excelnube84 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-14-2012, 04:22 AM

Tags for this Thread

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