6 Replies Latest reply on Jan 9, 2012 1:43 PM by LaRetta_1

# how many months between two dates

### Title

how many months between two dates

### Post

Hello All, Hello Phil,

I need to know how many months, if any, are included in a period of two dates, date1 and date2.

The formula I'm using as follows :

12 * ( Year ( date2 ) - Year ( date1) ) + Month ( date2) - Month ( date1) - ( Day ( date2) < Day ( date1) )

which gives me 1 month for the following dates : 01/01/2012 and 01/02/2012 . Ok.

But  0 month for 01/01/2012 and 31/01/2012.

Haven't been successfull yet trying to come up whith a valid formula.

Could you help ? Thanks in advance !

• ###### 1. Re: how many months between two dates

Hi

You are using file maker database.

So pls go  with its format e.g Month/Date/Year..

02/01/2012 and 01/01/2012 will give you 1 in FM format

1/31/2012 ---1//1/2012 will give you 0 months in FM Format.

Thanks

• ###### 2. Re: how many months between two dates

IF date 1 is 1/1/2012

Do you want a value of 1 month returned for all Date 2 values from

1/1/2012 to 2/1/2012?

• ###### 3. Re: how many months between two dates

Hilpnoires,

That calculation string you are using was from part of a larger calculation and 'month interpretation' was part of the original calc.  It would have produced 30 days 1/1/2012-31/1/2012 and produced 1 month for 1/1/2012-1/2/2012.

If a child was born yesterday then most people would say that the child is one day old today. If you were born on 25/3/2000, you will not be 'one year old' until 25/3/2001 ... this type of counting is NOT inclusive.

'Month' is a loose term and you will never get exact answers.  But in this case, duration usually is not inclusive.

Here is full calculation:  Newbie

• ###### 4. Re: how many months between two dates

I'm mixing you up with my foreign format, apologizes ; I will submit in US format next time.

If the month is complete, January 1st  2012 to January 31st  2012, for instance, value 1month.

If not complete,  January 1st  2012 to January 30th 2012, value 0 month.

Date1 and date2 can be any date, and the span years and months.

For the time being, this would suit me.

Thanks LaRetta for your post and your link, I'll read it carefully,  I didn't come across it when digging into the forum.

• ###### 5. Re: how many months between two dates

This is unusual. Normally, you would not consider the month "complete" until you reached the first of the next month.

• ###### 6. Re: how many months between two dates

Right, Phil, as I explained ... 1/1/2012 to 1/31/2012 is NOT a full month.

If you wish to have it be considered INCLUSIVE then simply add 1 to your calculation.