Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 5139 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I think this may be a quick one. I want a function that returns a Boolean result if a number is divisible by 4 ie it returns a whole number when divided by 4.

Is this possible.

Many thanks

Posted

The following function will return 1 if a number is evenly divisible by 4. It will return 0 otherwise.

If the number is zero it will return 0. This is an arbitrary choice, but since you asked for a whole number instead of an integer, that indicated to me that you needed a zero result when given zero as input.

Case(

theNumber = 0; 0; /* Make this result 1 if your logic

Mod(theNumber; 4) = 0; 1;

0

)

Posted

This:

returns a Boolean result if a number is divisible by 4

is NOT the same as:

it returns a whole number when divided by 4.

A Boolean result is either True (1) or False (0). To get a Boolean result if a number is divisible by 4, you can use =

not Mod ( number ; 4 )






To return a whole number when divided by 4 ... well it depends on whether you want to round, or discard the remainder, or whatever. The simplest way is:




Div ( number ; 4 )

which performs an integer division (i.e. any remainder is discarded).

Posted

The difference being... ?

I may be misremembering my elementary school math terminology. I thought a whole number was a "counting number", i.e. positive integers.

Integers of course can be zero and negative.

Posted

My dictionary defines "integer" as "a whole number". But it is true that the term does not have a precise definition and some use it to mean "a natural number".

Posted

Hi sorry did not intend to create a debate. I should have been clearer. Basically what I was looking for is if a number in this case a year was divisible by four (and would therefore denote a leap year) it would trigger conditional formating on the field I have for 29th Feb.

The not Mod ( number ; 4 ) worked like a dream

Thank you all for your help.

Posted

a year was divisible by four (and would therefore denote a leap year)

That's not a good test - it will fail in 2100. Try =

not Mod ( Year ; 4 ) and Mod ( Year ; 100 ) or not Mod ( Year ; 400 ) 




or =




Month ( Date ( 2 ; 29 ; Year ) ) = 2

Posted

... or:

DayOfYear( Date( 12 ; 31 ; Year ) ) = 366

... but this is kind-of the same as Month ( Date ( 2 ; 29 ; Year ) ) = 2

  • 3 weeks later...
Posted

If they are still using this databased in 2100 I will be impressed, although probably dead haha.

Thanks for the tip though will change my code.

This topic is 5139 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.