+ Reply to Thread
Results 1 to 5 of 5

IF statemetent refering to date and time

  1. #1
    Registered User
    Join Date
    09-04-2017
    Location
    England
    MS-Off Ver
    2010
    Posts
    3

    Post IF statemetent refering to date and time

    Hello,

    I'm wanting to automatically fill a cell depending on the date and time of two other cells.

    These are the statements I'm trying to formulate into one cell:

    1. Mon-Thurs, 08:01-17:00 = "A"
    2. Mon-Thurs, 17:01-08:00 = "B"
    3. Fri, 08:01-13:00 = "A"
    4. Fri, 13:01 - Sun, 17:00 = "C"

    I currently have a column with the date in, a column which reads the date and returns the day name (ie, A3=04/09/2017, A4=Mon) and a column with the time.

    Any help much appreciated!

    Many thanks

  2. #2
    Forum Expert cbatrody's Avatar
    Join Date
    04-15-2014
    Location
    Dubai
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    2,136

    Re: IF statemetent refering to date and time

    Hi,

    Welcome to the forum.

    Try the following formula in D1:

    =IF(OR(WEEKDAY(A2,1)=6,WEEKDAY(A2,1)=7,AND(WEEKDAY(A2,1)=5,C2>13/24)),"C",IF(OR(AND(WEEKDAY(A2,1)<=4,C2>8/24,C2<=17/24),AND(WEEKDAY(A2,1)=5,C2>8/24,C2<=13/24)),"A","B"))

    see the attached file.
    Attached Files Attached Files

  3. #3
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: IF statemetent refering to date and time

    Welcome to the forum.

    You can do this with a combination of IF, AND and OR using WEEKDAY(cell) and checks such as >=17/24 for time. However, the list you have above doesn't cover all the possibilities - what do you want for Fri before 08:00, for example? or Monday before 08:00? or Sunday after 17:00?

    The formula might start something like this, which will give you the 'A' for the Mon-Thu period:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    This assumes date in col A and time in col C - note that you don't need the separate day name column.

    Hope that helps.

    If you could say what you want for the other possibilities, we can build the rest for you as well.
    Regards,
    Aardigspook

    I recently started a new job so am a bit busy and may not reply quickly. Sorry - it's not personal - I will reply eventually.
    If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark this Thread as Solved'.
    If you use commas as your decimal separator (1,23 instead of 1.23) then please replace commas with semi-colons in your formulae.
    You don't need to give me rep if I helped, but a thank-you is nice.

  4. #4
    Registered User
    Join Date
    09-04-2017
    Location
    England
    MS-Off Ver
    2010
    Posts
    3

    Re: IF statemetent refering to date and time

    Ideal, thank you both!

    I've used both methods and slightly adapted them to suit but otherwise problem solved!

    Many thanks

  5. #5
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: IF statemetent refering to date and time

    Glad we were able to help and thanks for marking 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. Replies: 7
    Last Post: 06-19-2017, 06:10 PM
  2. find date, copy refering to the heders and one condition(in last row)
    By grzecheem in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-28-2015, 08:16 AM
  3. Replies: 9
    Last Post: 02-15-2015, 07:32 PM
  4. Replies: 3
    Last Post: 12-19-2013, 06:49 AM
  5. Calculation of time difference between the Start date & time & End Date & time
    By Harry Jones in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 12-17-2012, 03:54 PM
  6. Replies: 2
    Last Post: 06-24-2009, 01:11 PM
  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

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