Extract years between two dates

koolwaters

Active Member
Joined
May 16, 2007
Messages
403
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.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
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 <endVar?

Is that what you are looking for or am I way off?
 
Upvote 0
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.
 
Upvote 0
In B4:
=IF(ROWS($A$1:A1)<=DATEDIF($B$1,$B$2,"y")+1,YEAR($B$1)+ROWS($A$1:A1),"")

Copy down.

Excel Workbook
AB
1Start Date:9/7/2010
2End Date:8/30/2014
3
42011
52012
62013
72014
8
9
10
Sheet1
 
Upvote 0
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.
 
Upvote 0
Hi Montez659,

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

http://www.mrexcel.com/forum/showthread.php?t=537412

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.
Excel Workbook
ABCDEFGHIJKLM
1NameDeptDisclipineCourseDuration201020112012201320142015Amount RequestedApprove/Decline
2Jane Doe31MBA2101020Approved
3John Doe29BSC610101010101060Approved
Sheet1
Excel 2007
Cell Formulas
RangeFormula
L3=SUM(F3:K3)


I hope this helps to explain what I am trying to acheive.
 
Upvote 0
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?
 
Upvote 0
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. ;)
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top