Page 1 of 8 123 ... LastLast
Results 1 to 10 of 73

Extract years between two dates

This is a discussion on Extract years between two dates within the Microsoft Access forums, part of the Question Forums category; Hi, I need to extract the years between two dates. For example: Start Date 2010-09-07 End Date 2014-08-30 The number ...

  1. #1
    Board Regular
    Join Date
    May 2007
    Location
    Barbados
    Posts
    303

    Default Extract years between two dates

    Hi,

    I need to extract the years between two dates.

    For example:

    Start Date 2010-09-07
    End Date 2014-08-30

    The number of years between the Start Date and End Date are four.

    As part of my query result, I need to see only the years between these two dates. So I would see,

    2011 2012 2013 2014

    If I have
    Start Date 2010-09-07
    End Date 2013-08-30

    I need to see 2011 2012 2013

    I hope that someone can assist.

    Thanks in advance.
    Michelle

  2. #2
    Board Regular
    Join Date
    May 2005
    Location
    Undisclosed (I'd tell ya but...you know...)
    Posts
    912

    Default Re: Extract years between two dates

    Not sure quite what you are looking for. Is there another variable to determine Start Date and End Date? If so, wouldn't simply adding to the criteria of your field Start Date something like >startVar and in your End Date criteria having
    Is that what you are looking for or am I way off?
    "A leader without followers is just a guy taking a walk."

  3. #3
    Board Regular
    Join Date
    May 2007
    Location
    Barbados
    Posts
    303

    Default Re: Extract years between two dates

    I am not sure I follow, but what I want are the calendar years between my Start and End Dates.The Start and End Dates vary, so I am not sure how to accomplish that.
    Michelle

  4. #4
    MrExcel MVP
    Moderator
    Scott Huish's Avatar
    Join Date
    Mar 2004
    Location
    Oregon
    Posts
    16,079

    Default Re: Extract years between two dates

    In B4:
    =IF(ROWS($A$1:A1)<=DATEDIF($B$1,$B$2,"y")+1,YEAR($B$1)+ROWS($A$1:A1),"")

    Copy down.

    Sheet1

     AB
    1Start  Date:9/7/2010
    2End Date:8/30/2014
    3  
    4 2011
    5 2012
    6 2013
    7 2014
    8  
    9  
    10  

    Spreadsheet Formulas
    CellFormula
    B4=IF(ROWS($A$1:A1)<=DATEDIF($B$1,$B$2,"y")+1,YEAR($B$1)+ROWS($A$1:A1),"")


    Excel tables to the web >> Excel Jeanie HTML 4
    Office 2007/2010

    Be responsible for the questions you post. If you don't reply to answered questions, be it just a simple "yes, that worked," or even "thanks," the time someone took to help you goes unrewarded.

  5. #5
    Board Regular
    Join Date
    May 2007
    Location
    Barbados
    Posts
    303

    Default Re: Extract years between two dates

    Hi HOTPEPPER,

    I am trying to acheive that result in Access and would need my years in columns.
    Michelle

  6. #6
    MrExcel MVP
    Moderator
    Scott Huish's Avatar
    Join Date
    Mar 2004
    Location
    Oregon
    Posts
    16,079

    Default Re: Extract years between two dates

    Sorry, didn't see that this was an Access problem.
    Office 2007/2010

    Be responsible for the questions you post. If you don't reply to answered questions, be it just a simple "yes, that worked," or even "thanks," the time someone took to help you goes unrewarded.

  7. #7
    Board Regular
    Join Date
    May 2005
    Location
    Undisclosed (I'd tell ya but...you know...)
    Posts
    912

    Default Re: Extract years between two dates

    I am still having a hard time following what you need. You said this is a query but do you need it for a report?

    Try to lay out the whole scenario of what you are trying to do. I am having a real hard time picturing what you are looking for.
    "A leader without followers is just a guy taking a walk."

  8. #8
    Board Regular
    Join Date
    May 2007
    Location
    Barbados
    Posts
    303

    Default Re: Extract years between two dates

    Hi Montez659,

    I am trying to create a budget forecast report as detailed in the post below.

    Budeget Forecast Report for Tuition Assistance

    I have not received any replies to the post and am still trying to tackle it.

    This is a sample of what I am trying to acheive in an Access report but creating the query is a challenge. The years are not captured, only the Start Date and End Date.

    Sheet1
    ABCDEFGHIJKLM
    1NameDeptDisclipineCourseDuration201020112012201320142015Amount Requested Approve/Decline
    2Jane Doe31MBA2101020Approved
    3John Doe29BSC610101010101060Approved
    Excel 2007

    Worksheet Formulas
    CellFormula
    L3=SUM(F3:K3)



    I hope this helps to explain what I am trying to acheive.
    Michelle

  9. #9
    Board Regular
    Join Date
    May 2005
    Location
    Undisclosed (I'd tell ya but...you know...)
    Posts
    912

    Default Re: Extract years between two dates

    Is this sheet in a report?

    I guess what I am not understanding is what exactly are you querying for if all you have is the beginning date and ending date?
    "A leader without followers is just a guy taking a walk."

  10. #10
    Board Regular
    Join Date
    May 2005
    Location
    Undisclosed (I'd tell ya but...you know...)
    Posts
    912

    Default Re: Extract years between two dates

    Ok, I see from your link (that I should have read completely) that you are looking for a report and not necessarily a query.

    When you are forecasting for the future years, are there some records that would start in future years (i.e., they start in 2013 but they are in the db as of today)? Also, what is the maximum number of years that you want to forecast for?

    I am going to have to do some thinking about this, considering I saw your original post a while back and passed on it cause I thought it was above my head.
    "A leader without followers is just a guy taking a walk."

Page 1 of 8 123 ... LastLast

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
  •  


DMCA.com