We're aware that some users are experiencing technical issues which the team are working to resolve. See the Community Noticeboard for more info. Thank you for your patience.
📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!

Excel 2007 Query

Options
245

Comments

  • rmg1
    rmg1 Posts: 3,159 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    Try this:
    =IF(TEXT(A2,"dd/mm/yyyy")=TEXT(B2,"dd/mm/yyyy"),"Pass",IF(TEXT(A2,"dddd")="Friday",IF(AND(HOUR(A2)>=13,TEXT(B2,"dd/mm/yyyy")=TEXT(A2+3,"dd/mm/yyyy")),"Pass","Fail"),IF(AND(HOUR(A2)>=13,TEXT(B2,"dd/mm/yyyy")=TEXT(A2+1,"dd/mm/yyyy")),"Pass","Fail")))

    Similar to the first one but now takes the arrival day into account.
    Seems to work at a quick check.
    :wall: Flagellation, necrophilia and bestiality - Am I flogging a dead horse? :wall:

    Any posts are my opinion and only that. Please read at your own risk.
  • paddyrg
    paddyrg Posts: 13,543 Forumite
    Just to reassure you OP, business rules around dates are responsible for about half of the work in IT - it is always more complicated than it sounds! For instance when people want a stock list and a sales list and try to combine them, with some sort of tests for date ranges... Well it throws up about a zillion things you're touching the edges of! So be assured, it's not you being dumb, but surprisingly complicated!
  • Stompa
    Stompa Posts: 8,375 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    It seems to me that something like:

    =IF(dayout<1+WORKDAY(dayin,1-(HOUR(dayin)<13)),"Pass","Fail")

    should do the trick.
    Stompa
  • shaz77_2
    shaz77_2 Posts: 1,881 Forumite
    rmg1 wrote: »
    Try this:
    =IF(TEXT(A2,"dd/mm/yyyy")=TEXT(B2,"dd/mm/yyyy"),"Pass",IF(TEXT(A2,"dddd")="Friday",IF(AND(HOUR(A2)>=13,TEXT(B2,"dd/mm/yyyy")=TEXT(A2+3,"dd/mm/yyyy")),"Pass","Fail"),IF(AND(HOUR(A2)>=13,TEXT(B2,"dd/mm/yyyy")=TEXT(A2+1,"dd/mm/yyyy")),"Pass","Fail")))

    Similar to the first one but now takes the arrival day into account.
    Seems to work at a quick check.

    Thanks again, I've tried your code above but it return a parenthesis error which I can't resolve, do you know what the problem could be? I've removed all additional code that I had within the cell and it still doesn't seem to work.
  • shaz77_2
    shaz77_2 Posts: 1,881 Forumite
    shaz77 wrote: »
    Thanks again, I've tried your code above but it return a parenthesis error which I can't resolve, do you know what the problem could be? I've removed all additional code that I had within the cell and it still doesn't seem to work.

    Thought I'd bump this up again as it's been bugging me all day.
  • rmg1
    rmg1 Posts: 3,159 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    shaz77 wrote: »
    Thanks again, I've tried your code above but it return a parenthesis error which I can't resolve, do you know what the problem could be? I've removed all additional code that I had within the cell and it still doesn't seem to work.

    I've just copied the formula direectly into a cell and it works fine for me.
    Are you sure you grabbed all of the formula?
    :wall: Flagellation, necrophilia and bestiality - Am I flogging a dead horse? :wall:

    Any posts are my opinion and only that. Please read at your own risk.
  • shaz77_2
    shaz77_2 Posts: 1,881 Forumite
    It doesn't seem to recognise Fridays, at present if I put in the arrival date as 07/09/2012 14:00 and the despatch date as 08/09/2012 12:00 it is returning fail when this should be pass.

    I've copied across the code 3 times now to no avail.
  • Stompa
    Stompa Posts: 8,375 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    shaz77 wrote: »
    It doesn't seem to recognise Fridays, at present if I put in the arrival date as 07/09/2012 14:00 and the despatch date as 08/09/2012 12:00 it is returning fail when this should be pass.

    I've copied across the code 3 times now to no avail.
    I may be wrong, but I don't think that formula accommodates despatch dates that happen to be a Saturday or Sunday. I'd go with the simpler:

    =IF(B2<1+WORKDAY(A2,1-(HOUR(A2)<13)),"Pass","Fail")

    which I think should work in all circumstances.
    Stompa
  • shaz77_2
    shaz77_2 Posts: 1,881 Forumite
    I'm still not getting anywhere with these formulas, does anyone know how to combine the formulas to allow for weekends etc?
  • Stompa
    Stompa Posts: 8,375 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    shaz77 wrote: »
    I'm still not getting anywhere with these formulas, does anyone know how to combine the formulas to allow for weekends etc?
    Does the one I gave previously not work for you? And, if not, in what circumstances does it fail?
    Stompa
This discussion has been closed.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 350.8K Banking & Borrowing
  • 253K Reduce Debt & Boost Income
  • 453.5K Spending & Discounts
  • 243.8K Work, Benefits & Business
  • 598.7K Mortgages, Homes & Bills
  • 176.8K Life & Family
  • 257.1K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16.1K Discuss & Feedback
  • 37.6K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.