1 2 Previous Next 22 Replies Latest reply on Apr 20, 2009 3:40 AM by restos

# How to make this calculate value?

### Title

How to make this calculate value?

### Post

Hi there,

I need to make this formule in FIleMaker 9

Today - (other date) = X

X / 7 = two options:

1) If calculated result is an int number, this is the final value

2) If calculated result is not an int number then:

- Example: Result: 30.9

Then I need

30.9 - (its int, in this example: 30) = 0.9

0.9 x 7 = Final Value I need. (Value A)

Then I need two fields to show the calculated value

One field with result int, in example is 30

Other field with Value A

The result is type: 30 weeks and 3 days (Value A)

Any Help?

• ###### 1. Re: How to make this calculate value?

Let ( X = Get(CurrentDate) - table::datefield;

If (int(x/7) = x/7, x/7, mod(x; 7))

If I've done the math right in my head that should do it. If I'm wrong some other forum poster will tell me :smileywink:

• ###### 2. Re: How to make this calculate value?

I think you want:

cFullWeeks = Div ( Get ( CurrentDate ) - YourDate ; 7 )

cRemainingDays = Mod ( Get ( CurrentDate ) - YourDate ; 7 )

• ###### 3. Re: How to make this calculate value?

restos wrote:

The result is type: 30 weeks and 3 days (Value A)

All you need is a calculated text field with a calc of this type:

Let([
p = Abs ( date1 - date2 ) ;
w = Int ( p / 7 )  & " weeks" ;
d = Mod ( p ; 7 )
];
Case(
date1 * date2 and p ;
Case (
not d ; w ;
w &" and " &  d & " days"
)
)
)

where date1 and date2 are your date fields.

• ###### 4. Re: How to make this calculate value?

raybaudi,

When I insert this function,

• ###### 5. Re: How to make this calculate value?

Hi restos

1) create a calculated field, result text, and paste the calc above.

2) if you have two date fields, substitute their names to date1 and date2

3) if you have ONLY a date field, substitute date1 with : Get(CurrentDate) and date2 with your date field

4) in the last ipotesys, make this calculation UNSTORED.

• ###### 6. Re: How to make this calculate value?

I have a text filed, change to calculated text field and I paste:

"""""" Let([

p = Abs ( Get(CurrentDate) - FUR ) ;
w = Int ( p / 7 )  & " weeks" ;
d = Mod ( p ; 7 )
];
Case(
Get(CurrentDate) * FUR and p ;
Case (
not d ; w ;
w &" and " &  d & " days"
)
)

) """"""""

With no """"""""

FUR is my date2

I got the same issue.

How can I make this calculation UNSORTED?

• ###### 7. Re: How to make this calculate value?

Hi restos

If FUR is the name of your date field, you can't get the same issue.

Remember that the calculation do not need any initial ( nor ending ) quotes.

Even if still STORED, it has to give you a result of the type: 2 weeks and 3 days.

But, to have the calculation re-evaluate itself each day, that calculazion must be UNSTORED.
( at the buttom- right of the 'Specify Calculation' window there is a button: Storage Options... Click it and put a flag into the box: do not store calculation results )

• ###### 8. Re: How to make this calculate value?

date1 * date2  and p // what does that do? You're multiplying two dates and then concatenating P (an interval of time)?

not d // if d = 0 does that mean "not d" is true?

Case(
date1 * date2 and p ;

Case (
not d ; w ;
w &" and " &  d & " days"

• ###### 9. Re: How to make this calculate value?

Hi obeechi

date1 * date is the same of this:

not IsEmpty ( date1 ) and not IsEmpty ( date2 )

p is the same of p ≠ 0

So:

Case(
date1 * date2 and p

is the same that:

Case(
not IsEmpty ( date1 ) and not IsEmpty ( date2 ) and p ≠ 0

-------------

"not d // if d = 0 does that mean "not d" is true?"

Yes.

• ###### 10. Re: How to make this calculate value?

Well then you could also write it as

date1 * date2 * P

or as

date1 and date2 and P

??

I looked at using a calc of "date1 + date2" and was surprised that it functioned like an OR, meaning

that if date1 had a value and date2 did not have a value then the result was true, and likewise date1

had no value and date2 did have a value. Yet * seems to act like an AND. Seems counterintuitive and if

* and AND are equals maybe its less confusing to just use AND ???

• ###### 11. Re: How to make this calculate value?

obeechi wrote:

maybe its less confusing to just use AND ???

It's not only clearer - it also saves the need to compute the product of 2 6-digit numbers (which will be converted to a Boolean in the next step anyway).
• ###### 12. Re: How to make this calculate value?

Oh, gee

date1 * date2 is a product where if date1 OR date2 is equal to zero, then the product is equal to zero and therefore its FALSE, otherwise TRUE

okay, I get it, but I think Comments right.

• ###### 13. Re: How to make this calculate value?

obeechi wrote:

if date1 OR date2 is equal to zero...

A date can never be equal to zero but can be empty.

I didn't want the evaluation of that formula if date1 or date2 were empty or if p ( period ) was 0 ( startDate = endDate )

• ###### 14. Re: How to make this calculate value?

Hi again,

Can anybody take a look to my attached picture?

I think I have one error with it.

1 2 Previous Next