# FM - IF Statement Able to Check for Date on a Weekly Basis Forever

Want an IF statement that checks and sends a reminder email every week before and after a deadline date.  The only way I can think of doing this is to get the absolute value of the Deadline Date - Current Date, then divide by 7 and only get a true IF statement if the result is a whole number (no decimals).  How would I do that?  I don't see an absolute value sign in the FM dialog box, etc.  Thank you.
LVL 2
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PresidentCommented:
Filemaker has the Abs() function which will give you the absolute value, in this case of DeadlineDate - Get ( CurrentDate ) . The result is one if it's met.

Case( Abs( DeadlineDate - Get ( CurrentDate ) ) = 7 ; 1 )
0
Author Commented:
And finding a whole number could be the absence of a decimal as in

PatternCount ( GetAsText ( Field ) ; "." ) = 0                  ???
0
Author Commented:
PatternCount ( ( WORKORDERS::WorkDeadline - Get ( CurrentDate ) ) / 7  ; "." ) = 0
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
Actually, ends up you don't need to take the absolute value after all.
0
PresidentCommented:
I wouldn't use pattern count to check for a decimal point since one might have been entered manually and you can never tell if the field result is set correctly to number or incorrectly to text. If yo want to test for whether something has a decimal you can use:

Case( someField = Int( someField ;"this is a whole number" ;  "decimal value present")

Int() being the Integer function which gives you the non-decimel part of a number, e.g. Int( 3.14159 ) = 3  It is not the same as rounding.

The number minus the Int() version of the number will give you just the decimal part.

Another useful similar function is Mod() which gives only the remainder of a division calc and can be used to determine odd/even. e.g. Mod( 4 ; 2 ) = 0 and therefore is even, Mod( 5 ; 2 ) = 1 and therefore is odd.  http://www.filemaker.com/12help/html/func_ref3.33.35.html
0
Author Commented:
Final, Final Answer per my IF statement for my Database:

( WORKORDERS::WorkDeadline - Get ( CurrentDate ) ) / 7  =
Int ( ( WORKORDERS::WorkDeadline - Get ( CurrentDate ) ) / 7 )
0
PresidentCommented:
Why not use:

Abs( WORKORDERS::WorkDeadline - Get ( CurrentDate ) ) = 7

It will only work on the two dates that are one week before and one week after...no Int() required.

Note that if it's an indexed calc it may not work as expected. It needs to be unindexed so the Get ( CurrentDate ) calculates every time.
0
Author Commented:
My boss wants the weekly reminders indefinitely until the work order is closed.  Also, I'm putting this in a script, not a field, so the indexing doesn't apply.
0
PresidentCommented:
OK, then you want to use the Mod() function.

Mod( Abs( WORKORDERS::WorkDeadline - Get ( CurrentDate ) ) ; 7 ) = 0

the Result is True if the difference between the dates is a multiple of 7.
0
Author Commented:
Does this account for if the WorkDeadline equals Get ( CurrentDate ) ?
0
PresidentCommented:
If you don't want it to include the actual day, then just exclude that:

case(
WORKORDERS::WorkDeadline <> Get ( CurrentDate ) and
Mod( Abs( WORKORDERS::WorkDeadline - Get ( CurrentDate ) ) ; 7 ) = 0
; 1 )
0
Author Commented:
Actually, no I meant I wanted to include it.
0
PresidentCommented:
Then the Mod calc alone should do it because 0 divided by 7 is still zero so there is no remainder and the test is True.
0
Author Commented:
Thanks Will, gave me the missing piece.
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
FileMaker Pro

From novice to tech pro — start learning today.