+ Reply to Thread
Results 1 to 19 of 19

Start and End Dates for Consecutive Dates

  1. #1
    Registered User
    Join Date
    09-28-2017
    Location
    Toronto, Canada
    MS-Off Ver
    2007
    Posts
    6

    Start and End Dates for Consecutive Dates

    Hi,

    I need help....I have a list of id numbers with absence dates. I need to be able to identify the start and end date of each consecutive absence where start date is column b and end date would be column c with the number of consecutive days in column d. Any single day absence would be included as well. We do not work weekends or holidays.

    I have attached a list of my current data.

    Please let me know if you need anymore information.

    Thanks,

    Melissa
    Attached Files Attached Files

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Start and End Dates for Consecutive Dates

    You can use the formula NETWORKDATES(startdate, enddate) which will give you the net days (no weekends) and if you have a list of holiday dates you can add that too, but
    The list you say are absence dates when did the abscence end?
    The example below is using NETWORKDAYS(date in B2, date in B3) just to show the results but this doesn't make sense.


    Please Login or Register  to view this content.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Start and End Dates for Consecutive Dates

    Try this - be sure to have a backup!

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  4. #4
    Registered User
    Join Date
    09-28-2017
    Location
    Toronto, Canada
    MS-Off Ver
    2007
    Posts
    6

    Re: Start and End Dates for Consecutive Dates

    So I tried running and I am not getting any data.

    I don't know if this will help at all

    I need it read something like this ...obviously I have done this manually

    ID Start of absence End of Absence # of Consecutive days
    10 1/22/2015 1/22/2015 1
    10 1/29/2015 1/29/2015 1
    10 2/26/2015 2/26/2015 1
    10 3/11/2015 3/11/2015 1
    10 4/20/2015 4/21/2015 2

    I can't thank you enough for looking at this

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Start and End Dates for Consecutive Dates

    This is the result of the run on my system:
    Attached Files Attached Files
    Last edited by xladept; 10-05-2017 at 09:25 PM.

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Start and End Dates for Consecutive Dates

    All this is very nice but if you read what I mentioned in #2, this is a list of ABSENCE dates and nowhere the OP mentions when the this ends.
    Everyone is assuming that the next date is the return date but that is and remains an assumption.
    Incorrect information will return incorrect answers.
    So let the OP take care that the information provided is complete and then we can help

  7. #7
    Registered User
    Join Date
    09-28-2017
    Location
    Toronto, Canada
    MS-Off Ver
    2007
    Posts
    6

    Re: Start and End Dates for Consecutive Dates

    Hi,

    I apologize I thought I explained my needs in my original post but when I read above I obviously did not clarify. We are currently implemented an absence program with multiple dynamics but we do not have the resources at this time to program a lot of the reports I need run the program so I need to work with the data I currently have. Right now I can pull a list of absences. Each absence is list as an individual absence. I have a couple of needs and maybe you guys may have a better way to structure the information but I need to identify any consecutive absence and how many days occur within that absence.

    As Keebellah, indicated the assumption was that the next absence in the list was the end of absence. That is not a correct assumption. The start date would the first date in the series of consecutive dates and end date would be the last date in the series consecutive dates.

    I hope that clarifies. Please let me know if I need to explain more details.

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Start and End Dates for Consecutive Dates

    So - what's wrong with my program? It seems to give you exactly what you want??

  9. #9
    Registered User
    Join Date
    09-28-2017
    Location
    Toronto, Canada
    MS-Off Ver
    2007
    Posts
    6

    Re: Start and End Dates for Consecutive Dates

    I don't think Iwas clear about what I was looking for. And I am sorry about that. When I look at your program it gives me the first date in the data set as the start date then the end date as the second date in the data set. The data from your program then reads that there is 7 absences that occurred between those two dates. But when you go back to my original data there is no absences in January 23, 24...etc. What I am looking for is January 22 is the start date because the next date in the data is not a consecutive date that is the end of the occurrence. So January 22 is one occurrence with 1 day taken. The same would be for January 29, February 22 and March 11. then we get to the April 20, April 21 and April 24. April 20 and April 21 are consecutive dates so they would be a consecutive absence which is one occurrence with two days. Because April 24 is not a consecutive date it would start a new occurrence. My logic was cell b2 would be the first start date. If the ids were the same and b2 does not equal the b2+1 then it would be the end date but if b2 does = b2+1 the ignore and continue until the dates are no longer consecutive. Then I would need in the next column the number of consecutive days that occurred in the range. I just don't know how to write this especially factoring in that we do not work weekends or holidays.

    I hope that makes more sense if not I can try to explain another way

    Cheers

  10. #10
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Start and End Dates for Consecutive Dates

    Thanks for the 'enlightment'; but... again an assumption (I hate these you know what ASSUME stands for : it makes an A S S out of U and M E; nothing personal, it's just the fact I have seen projects going down the drain because of assumptions.
    But now back to your question.
    You have a list of dates which are dates that the ID is absent, correct so far?
    So if the next date is consecutive (that means that if one is a Friday and the Next is Monday it's consecutive since you do not work Weekends you keep on adding until there ia more than a day's gap and then a new abscense is recorded?

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,589

    Re: Start and End Dates for Consecutive Dates

    MissC,

    Is this how you wanted?
    Please Login or Register  to view this content.

  12. #12
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Start and End Dates for Consecutive Dates

    Try this:

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    09-28-2017
    Location
    Toronto, Canada
    MS-Off Ver
    2007
    Posts
    6

    Re: Start and End Dates for Consecutive Dates

    Sorry for the delay. It's Thanksgiving weekend in Canada so it's been quite hectic.

    Yes Keebellah, your assumption is correct.

  14. #14
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Start and End Dates for Consecutive Dates

    Thanks for the feedback.
    Maybe somebody else picks it up too, but I'll take a shot at it later today.

  15. #15
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Start and End Dates for Consecutive Dates

    Can you provide a list of Canadian Holidays? just dates and holiday name

  16. #16
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Start and End Dates for Consecutive Dates

    No much yet, just some tryouts.
    Sheet 2 has the holiday's list starting 2014 to 2015 which is the minimum year in sheet 1 and the maximum year in sheet 1
    The macro to update Sheet 2 is in Sheet 2 and the holidays vba is in the module
    Like I said, I just started looking and see what I encounter.
    Column C tells me it's one day (value 0) and column D is NETWORKDAYS using the HOLIDAYS named range.

    Little by little ...

  17. #17
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Start and End Dates for Consecutive Dates

    Okay this does the job.
    There is a holiday routine that builds the holidayslist (Sheet2) based upon then minumum year and maximum year in your absentee list (Sheet1)

    Sheet3 will be refreshed when you press the green calendarlike icon on Sheet1 using the list in sheet1

    Only requirement is that the list is sorted by ID and ascending Date
    Not much comments in the vba code, just see if it works for you.

    The holidays must be coded in the vba code, like specific Thanksgiving in Canada which is different than the US

  18. #18
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Start and End Dates for Consecutive Dates

    Removed a redundant vba code, one IF condition was enough

  19. #19
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Start and End Dates for Consecutive Dates

    Hi, I just want to let you know that I'm overwhelmed by your enthusiasm

+ 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: 17
    Last Post: 02-14-2024, 07:07 AM
  2. [SOLVED] Count instance of >8 days between consecutive dates in a list of dates
    By Keats713 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-07-2017, 11:18 AM
  3. Populating list of dates from another sheet with Start Dates and End Dates
    By Jesshloly in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-05-2015, 04:07 AM
  4. [SOLVED] Creating a formula to populate range of cells between dates based on start and end dates
    By Rainmain82 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-18-2014, 07:55 AM
  5. Find the start and end date of range of consecutive dates.
    By aguirre.m36 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-25-2013, 09:24 PM
  6. Replies: 9
    Last Post: 03-05-2012, 08:17 AM
  7. Replies: 5
    Last Post: 06-30-2011, 03: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