+ Reply to Thread
Results 1 to 9 of 9

Returning a value if cell date is between two dates

  1. #1
    Registered User
    Join Date
    02-08-2010
    Location
    Madison, Wisconsin
    MS-Off Ver
    Excel 2007
    Posts
    47

    Returning a value if cell date is between two dates

    I have dates in column A for the whole year (format: Wednesday July 12, 2010). I need a formula in column B to return a value of 1 if the date is between two specific dates.
    Last edited by joeljoel; 11-22-2010 at 12:28 AM.

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Returning a value if cell date is between two dates

    Assuming dates are in A1:A365, and the start and end dates are in C1 and D1, in B1 use

    =AND(A1>=$C$1,A1<=$D$1)*1

  3. #3
    Registered User
    Join Date
    02-08-2010
    Location
    Madison, Wisconsin
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: Returning a value if cell date is between two dates

    What if I want those dates to be specified in this way - March 1, 2010 and October 31, 2012. That's what I really need to do.

    Thanks!

  4. #4
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Returning a value if cell date is between two dates

    You can format a date any way you want. The cell can contain 1/18/2010 but be formatted to appear as "mmmm d, yyyy" and you can still check if it's in a range.

    If your "dates" are actually just text strings that Excel doesn't recognize as dates, it gets a little more complicated.

  5. #5
    Registered User
    Join Date
    02-08-2010
    Location
    Madison, Wisconsin
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: Returning a value if cell date is between two dates

    Paul, I appreciate the help.

    here's my formula =AND(A6>=10/1/2014,A6<=3/31/2016)*1
    and it doesn't seem to be working. Any idea what I'm doing wrong?

    Thanks!!

  6. #6
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Returning a value if cell date is between two dates

    In your formula, it is seeing '10/1/2014' as 10 divided by 1 divided by 2014, not a date. Try:

    =AND(A6>=DATE(2014,10,1),A6<=DATE(2016,3,31))*1

  7. #7
    Registered User
    Join Date
    02-08-2010
    Location
    Madison, Wisconsin
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: Returning a value if cell date is between two dates

    Awesome, Paul. That's the trick, thank you. The one thing I just couldn't get right was formatting the date. I have problems with this.

    Thanks!!

  8. #8
    Registered User
    Join Date
    03-24-2016
    Location
    London, UK
    MS-Off Ver
    2016
    Posts
    32

    Re: Returning a value if cell date is between two dates

    Hi,

    I have 4 tasks that are done in an order. First task1, then task 2 so on. Each task takes certain number of days.

    I have calculated Start & End date for each task using MIN & MAX from a list dates Sheet 1(from the beginning of task 1 till the end of last task 4).

    For example

    Sheet 2

    A ---------- B --------- C
    (Task) (Start Date) (End Date)


    Task 1 -- 1-Jan --- 6-Jan
    Task 2 -- 7-Jan -- 12-Jan
    Task 3 -- 13-Jan -- 14-Jan
    Task 4 -- 15-Jan -- 16-Jan

    Sheet 3

    In this sheet I have a "column D" for Dates, starting from 1-Jan till 16-Jan (beginning of Task1 - end of task 4) D2:D17
    In the same sheet I have marked "W" for working day, "H" for holiday & "A" for Absent, "S"for Sunday in "column F"

    D -------- E ------- F

    1-Jan Friday ------ W
    2-Jan Saturday --- W
    3-Jan Sunday ----- S
    4-Jan Monday ----- H
    5-Jan Tuesday ---- A
    6-Jan Wednesday - W
    .
    .
    .
    16-Jan Saturday --- W

    Now, I want to calculate the number of working days ("W") between start & end date for each task. For Task1, it should first check if each cell in column D (D2:D17) is in between 1-Jan & 6-Jan, if yes, count "W" in column F.

  9. #9
    Forum Contributor
    Join Date
    01-09-2016
    Location
    Perth Western Australia
    MS-Off Ver
    Office 365
    Posts
    257

    Re: Returning a value if cell date is between two dates

    Excel 2016 has a function to calculate the number of working days between 2 dates , have you looked at this to meet your needs?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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