+ Reply to Thread
Results 1 to 7 of 7

Subtract 1hr in excel and adjust the result if it falls outside office hours

  1. #1
    Forum Contributor
    Join Date
    06-24-2013
    Location
    philippines
    MS-Off Ver
    Excel 2007
    Posts
    199

    Subtract 1hr in excel and adjust the result if it falls outside office hours

    hello experts

    need your help please on how i can subtract 1 hour from a date and time, and if the result falls outside working hours, it would be adjusted to the last working hour. All results should only fall between Mon - Fri, 9:00 - 17:00

    example:

    column A result should be
    lu 01/03 15:00 - lu 01/03 14:00
    vi 05/03 13:00 - vi 05/03 12:00
    vi 26/02 08:00 - ju 25/02 17:00
    sá 27/02 18:00 - vi 26/02 17:00
    lu 01/03 06:00 - vi 26/02 17:00

    i can only subtract the 1 hour.. but not sure how to proceed how to formulate the working hours.

    Thanks in advance for the help!!

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: Subtract 1hr in excel and adjust the result if it falls outside office hours

    Administrative note

    Welcome to the forum

    in your haste to solve your problem, you probably missed the yellow banner advising how to get answers faster by posting a sheet ?

    Please take a moment to read it and attach a sheet accordingly.

    Thanks you for helping us help you

  3. #3
    Forum Contributor
    Join Date
    06-24-2013
    Location
    philippines
    MS-Off Ver
    Excel 2007
    Posts
    199

    Re: Subtract 1hr in excel and adjust the result if it falls outside office hours

    sorry about that... attaching the sample file here
    Attached Files Attached Files

  4. #4
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,408

    Re: Subtract 1hr in excel and adjust the result if it falls outside office hours

    Just checking... based on the file you posted, your "dates" are not real dates formatted to look like that, rather, they are purely text entries, correct? How did you want your answers back... as real dates or as text? I am guessing that "lu", "vi", etc. are two character abbreviations for day names in your native language... cell formatting won't be able to reproduce that but VBA code can. If you want real dates, is a VBA solution acceptable or can you work with three character day name abbreviations?
    Last edited by Rick Rothstein; 03-06-2021 at 12:37 PM.

  5. #5
    Forum Contributor
    Join Date
    06-24-2013
    Location
    philippines
    MS-Off Ver
    Excel 2007
    Posts
    199

    Re: Subtract 1hr in excel and adjust the result if it falls outside office hours

    hello rick..

    thank you for looking into the file. input and output should be in date and time. i am attaching a new excel file with the correct format.
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    06-24-2013
    Location
    philippines
    MS-Off Ver
    Excel 2007
    Posts
    199

    Re: Subtract 1hr in excel and adjust the result if it falls outside office hours

    any help from anybody?

  7. #7
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,899

    Re: Subtract 1hr in excel and adjust the result if it falls outside office hours

    Try this in cell B2:

    =IF(OR(WEEKDAY(A2,2)>5,MOD(A2,1)<10/24),WORKDAY(A2,-1)+17/24,A2-1/24)

+ 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] How to adjust row height of row so tall the point to grab to adjust auto falls below
    By juntjoo in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 06-22-2016, 02:07 PM
  2. If time period falls outside of normal working hours how many hours does it add.
    By chrisdromey in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-02-2013, 11:56 PM
  3. [SOLVED] Yes/No Result if a date value falls 'In Hours'
    By Flydd in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-03-2012, 02:26 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