
1. Re: How to make this calculate value?
philmodjunk Apr 17, 2009 10:49 AM (in response to restos)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?
comment_1 Apr 17, 2009 10:59 AM (in response to restos)I think you want:
cFullWeeks = Div ( Get ( CurrentDate )  YourDate ; 7 )
cRemainingDays = Mod ( Get ( CurrentDate )  YourDate ; 7 )

3. Re: How to make this calculate value?
raybaudi Apr 17, 2009 11:19 AM (in response to restos)
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?
restos Apr 18, 2009 3:38 AM (in response to restos)raybaudi,
When I insert this function,
"The field specify not found"

5. Re: How to make this calculate value?
raybaudi Apr 18, 2009 4:25 AM (in response to restos)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?
restos Apr 18, 2009 4:41 AM (in response to restos)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?
raybaudi Apr 18, 2009 10:45 AM (in response to restos)Hi restos
your first issue was: "The field specify not found"
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 reevaluate 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?
obeechi Apr 18, 2009 3:07 PM (in response to restos)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?
raybaudi Apr 18, 2009 3:36 PM (in response to restos)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 pis 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?
obeechi Apr 18, 2009 4:12 PM (in response to restos)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?
comment_1 Apr 18, 2009 5:03 PM (in response to restos)
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 6digit numbers (which will be converted to a Boolean in the next step anyway). 
12. Re: How to make this calculate value?
obeechi Apr 18, 2009 5:19 PM (in response to restos)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?
raybaudi Apr 18, 2009 5:36 PM (in response to restos)
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 )
