Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calculate the months between two dates

Status
Not open for further replies.

kenwood1

Technical User
Sep 4, 2007
6
AU
I have a start date (01/08/2015) and an end date (01/09/2016) and I want to know the number of months between them ......
 
Hi,

"Month" is an imprecise term, as they can vary: 28, 29, 30, 31 days per month.

So you must be more precise than just "months."

Would you ever use two dates like 7/1/2015 and 9/30/2015 and if so, what would your answer be?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Hi Skip,

The actual day is irrelevant, I just need a count of the months.....

eg. 08/2015 to 10/2016 is 15 months

Ken,
 
Neither of those are DATES!

So how many months in your first example?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
I'm with Skip in that you need to define what you mean by months. It would help if you provided some examples. There is a DateDiff() function but it returns the number of date borders crossed. For instance:

Code:
 DateDiff("m",#7/31/2015#,#8/1/2015#) = 1 
 DateDiff("m",#7/1/2015#,#8/31/2015#) = 1 

 DateDiff("d",#7/31/2015#,#8/1/2015#) = 1 
 DateDiff("d",#7/1/2015#,#8/31/2015#) = 61

As you can see two dates that are a single day apart and 61 days apart have the same month date difference.


Duane
Hook'D on Access
MS Access MVP
 
Guys I am probably not explaining myself clearly, we have jobs that are setup with an actual start date say(01/08/2015) and an estimated completion date of say (01/09/2016) and I simply want to count the number of months (as a number) between actual start date and estimated completion date to create report columns.

Ken
 
Did you read and understand Duane's last post?

Did you try the DateDiff() function?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
If all you want is the months, you'll need to do the following equation
#Months = Month(Date 2) - Month(Date 1) + 12*(Year(Date 2) - Year (Date 1))

You can do this calculation in VB or using basic Excel functions
 
Fuzzy math!

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top