5 Replies Latest reply on Nov 4, 2015 1:45 PM by davidhead

Help with a calculation to work out 6 months

Hi all,

I want to put a calculation into my system which is for billing.

I need to get it to work out from the start of the month then look 6 months ahead.  For example I'd like it to show that the client will be billed from

1 October 2015 through 31 March 2016.  I can't use days as obviously there are a differing amount of days in months and also it needs to show from start date to end date.

Any ideas?

TIA

Jackmac

• 1. Re: Help with a calculation to work out 6 months

You can try this:

Let (

d = theDate - Day ( theDate ) + 1

;

Date ( Month ( d ) + 6 ; Day ( d ) ; Year ( d ) ) - 1

)

... added ... if it is always based upon the current date and not one stored in your record, you can substitute Get ( CurrentDate ) for theDate

• 2. Re: Help with a calculation to work out 6 months

Hi Jackmac,

did you have a look at date functions ? Look at Date (Date(month; day; year) where you can create a date as you wish.

For example Date (16; 1; 2015) returns 1 April 2016. 16 means 6 months after 10th month, in other words 6 months after the 1st of October.

Gilles Plante

• 3. Re: Help with a calculation to work out 6 months

This will give you the first day of the month for a given date in a field called theDate:

Date ( Month (theDate) ; 1 ; Year (theDate) )

This will give you the last day of the month in six months from a given date in a field called theDate:

Date ( Month (theDate) + 6 ; 1 ; Year (theDate) ) - 1

• 4. Re: Help with a calculation to work out 6 months

Which can be further abbreviated to

Date ( Month (theDate) + 6 ; 0 ; Year (theDate) )

• 5. Re: Help with a calculation to work out 6 months

Very true.

What I was looking for was visual compatibility between the two expressions.

This expression:  Date ( Month (theDate) + 6 ; 1 ; Year (theDate) ) - 1

Says: "get the first day of the month of the date in six months, then go to the day before which is the last day of the previous month"

This expression: Date ( Month (theDate) + 6 ; 0 ; Year (theDate) )

Says: "get the zeroth day of the month of the date in six months, that is the day before the first day, which is the last day of the previous month"

Although the 0 day works and is supported by FileMaker clients, it requires further mental work to interpret.

Different programming styles. Both valid.