+ Reply to Thread
Results 1 to 13 of 13

Dates and IFs Query

  1. #1
    Registered User
    Join Date
    05-09-2014
    MS-Off Ver
    Excel 2010
    Posts
    28

    Dates and IFs Query

    Hi,

    I'm having a bit of trouble with the IF formula in my spreadsheet, see attached.

    I'm trying to populate the green colored cells with the return value in column A. Only if the start and end dates in column B and C fall within a particular week. I have highlighted the cells in red where I'm experiencing the problems.

    For example; row 2 has a start and end date from 20-May to 30-Jun. I would like this to be shown in the spreadsheet across the corresponding weeks, however, cell Q2 does not return the value in column A, even though this week falls within the start and end dates in columns B and C.

    Not sure if the formula I have done is wrong for this type of update but will appreciate your help, my IF formula knowledge is limited.

    The attached is example data and may not seem significant but in practice this spreadsheet is much larger and more importantly the start and end dates are likely to change throughout the course of the year, so having the green colored cells update automatically will save me a huge amount of time.

    Appreciate your Excel help! Please let me know if you need anything else. I hope I have explained my problem well enough.

    Thanks,
    J
    dates example.xlsx
    Last edited by jaredf; 02-13-2015 at 12:06 PM.

  2. #2
    Forum Expert
    Join Date
    09-11-2014
    Location
    Washington, DC
    MS-Off Ver
    2016
    Posts
    1,907

    Re: Dates and IFs Query

    Would this work? Paste into F2 and drag across/down:
    Please Login or Register  to view this content.
    Spread the love, add to the Rep

    "None of us are as smart as all of us."

  3. #3
    Registered User
    Join Date
    05-09-2014
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Dates and IFs Query

    Hi,

    Thanks for the speedy response. This has worked for updating one of the red cells I had a problem with but not the rest. It worked for cell L3, but not for Q2..

    Its when the date starts during the middle of any particular week is when the problem occurs.
    Last edited by jaredf; 02-13-2015 at 12:20 PM.

  4. #4
    Forum Expert
    Join Date
    09-11-2014
    Location
    Washington, DC
    MS-Off Ver
    2016
    Posts
    1,907

    Re: Dates and IFs Query

    It doesn't work for Q2 because Q2 doesn't fall within the range 5/20/2015 to 6/30/2015, and therefore returns as "". Also, your B4 and C4 values look incorrect. 4/13/2015 is after 4/5/2015.

  5. #5
    Registered User
    Join Date
    05-09-2014
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Dates and IFs Query

    Yes you are right, I have populated the example data incorrectly there for B4 and C4, sorry for this. However, for cell Q2, this week starts on 18-May and finishes on 24-May. The start date for this row is 20-May so it starts mid week which I think is causing the issue? Appreciate your help with this

  6. #6
    Forum Expert
    Join Date
    09-11-2014
    Location
    Washington, DC
    MS-Off Ver
    2016
    Posts
    1,907

    Re: Dates and IFs Query

    Okay then will something like this work? In F2 paste this and drag through U2:

    Please Login or Register  to view this content.
    Then in F3 paste this and drag down/across to fill:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-09-2014
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Dates and IFs Query

    Thanks. Definitely getting closer, some of the return values are still missing across a few cells, see attached. Should I be displaying the dates differently to make it easier? I'm not sure to be honest, I appreciate you helping
    dates example (2).xlsx

  8. #8
    Forum Expert
    Join Date
    09-11-2014
    Location
    Washington, DC
    MS-Off Ver
    2016
    Posts
    1,907

    Re: Dates and IFs Query

    It seems like the problem stems from the exception of Q2. Maybe if you explain what your spreadsheet is being used for, I can assist better.

  9. #9
    Registered User
    Join Date
    05-09-2014
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Dates and IFs Query

    It's like a project road map. Each row we'll have the different sub-projects listed in column A, with their start and end dates in columns B and C. During the course of the year these projects start and end dates will change because of external factors. From this document it's very easy for us to plan each project if one is delayed or vice versa (completed ahead of time). It's visual purpose plays a big role in planning. For example; if project c is delayed a few weeks how does this look if we are to start at this date or another date. It becomes easier for us to visualize how we're progressing against the road map; where are we behind or ahead because some projects cannot start until some have finished etc...

    Hope this adds some more detail. Let me know if you need anything else. Thanks again

  10. #10
    Forum Expert
    Join Date
    09-11-2014
    Location
    Washington, DC
    MS-Off Ver
    2016
    Posts
    1,907

    Re: Dates and IFs Query

    This should do it then. It was helpful knowing the background of the project because I was able to roll up the two previous formulas into one succinct one that should do the trick. Paste into F2 and drag across/down:

    Please Login or Register  to view this content.

  11. #11
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Dates and IFs Query

    I would probably try to avoid using WEEKNUM function in these type of calculations because it won't work as required when comparing dates at the start end of the year, e.g. you might expect Wed 31/12/2014 to be in the same week as the following day, Thu 1/1/2015.....but WEEKNUM says they are in different weeks.

    This formula in F2 copied across and down gives the required results

    =IF(AND($B2-WEEKDAY($B2,3)<=F$1,F$1<=$C2),$A2,"")
    Audere est facere

  12. #12
    Forum Expert
    Join Date
    09-11-2014
    Location
    Washington, DC
    MS-Off Ver
    2016
    Posts
    1,907

    Re: Dates and IFs Query

    Quote Originally Posted by daddylonglegs View Post
    I would probably try to avoid using WEEKNUM function in these type of calculations because it won't work as required when comparing dates at the start end of the year, e.g. you might expect Wed 31/12/2014 to be in the same week as the following day, Thu 1/1/2015.....but WEEKNUM says they are in different weeks.

    This formula in F2 copied across and down gives the required results

    =IF(AND($B2-WEEKDAY($B2,3)<=F$1,F$1<=$C2),$A2,"")
    Didn't think of that scenario, good catch. Excel is good for a lot of things, but I try and stick to MS Project when doing any IMS scheduling.

  13. #13
    Registered User
    Join Date
    05-09-2014
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Dates and IFs Query

    Thank you both for your help, this has worked! This has and will help me a lot, thanks again!

+ 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] Trying to Query between two dates
    By smls in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-04-2014, 03:24 PM
  2. Help with web query dates please.
    By enzihsehtsilecxe in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-23-2012, 10:34 PM
  3. How do I export dates into a query?
    By tires85 in forum Excel General
    Replies: 0
    Last Post: 08-11-2006, 04:20 PM
  4. web query in VBA (format dates in url)
    By slimswol in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-11-2006, 05:25 AM
  5. dates in query
    By patrick @fizz in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 04-08-2005, 03:06 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