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 4885 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I have a field for people names and a field for their birthdays. I like to have a field that calculates the remaining days for their birthdays so that I can sort the upcoming birthdays in an ascending or descending order.

Thanks.

Posted

I'm a bit rusty but try this:

Let ( [

d = Get ( CurrentDate ) ;

thisDOB = Date ( Month ( DOB ) ; Day ( DOB ) ; Year ( d ) ) ;

nextDOB = Date ( Month ( DOB ) ; Day ( DOB ) ; Year ( d ) + 1 ) ;

days = Case ( thisDOB < d ; nextDOB ; thisDOB ) - d

] ;

If (

thisDOB = d ; "Happy Birthday!!!" ;

days & " day" & Case ( days > 1 ; "s" ) & " until your birthday."

)

)

Result of this calculation is text and check 'do not store calculation results...' in the Storage Options so it updates. :smile:

UPDATED: improved calc per suggestion below

  • Like 1
Posted

Yikes, you changed the requirements! If you only want the number of days then change the calc to result of number:

Let ( [

d = Get ( CurrentDate ) ;

thisDOB = Date ( Month ( DOB ) ; Day ( DOB ) ; Year ( d ) ) ;

nextDOB = Date ( Month ( DOB ) ; Day ( DOB ) ; Year ( d ) + 1 )

] ;

Case ( thisDOB < d ; nextDOB ; thisDOB ) - d

)

UPDATED: improved calc per suggestion below

Posted

I’m not sure I agree and the calcs show different results. Can we walk through the logic?

result of ThisDOB - d might be -97. If so:

-97 < 0 is Boolean test which would return true.

-97 is number result which would return true but so would 369.

Take date of 8/31/xxxx. I suppose I could have used Sign() or reversed the Case() but ... :^)

Posted

Oooops. I misread < for -. :blush2: I now see what you mean. :laugh2: Of course! DOH! I AM rusty!

UPDATE: I am going to correct both calcs in case someone see the calc and grabs it without reading the rest of the thread.

Posted

The logic is that a - b returns a negative result if (and only if) b is larger than a.

Another way to look at it is in terms of an equation: you can add the same value to both sides. Start with:

a - b < 0

and add b to both sides.

  • 2 weeks later...
Posted

Thanks. The calculation works fine; however, it does not update the results with current date changes.

This topic is 4885 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.