Hi. If I understand correctly, what you are wanting is that a bird's age value in the calendar year it is seen is 1, in the next calendar year is 2 and so forth. If that is what you want try setting the age field as a calculation field with this calc:
If ( Year ( Get ( CurrentDate ) ) = Year ( datebirdseen ) ; 1 ; Year ( Get ( CurrentDate ) ) - Year ( datebirdseen ) + 1 )
Hope this helps.
Don't even need the IF, just
(Year (current date) - Year (bird seen date) )+1
[spelling out date functions as you did, of course]
True! Much simpler
Thank you for all the reply´s, but I still did not solve the problem.
I will try to build a better example:
The database is for ringed birds (Birds that where fitted with a leg ring for study purposes), and I have. The birds can be classified in age in this categories:
1cy (born in the current calendar year)
2cy ( born in the previous calendar year)
3cy ( born 2 calendar years ago)
4cy (born 3 calendar years ago)
And I have the date of ringing, the date where the bird is fitted with a ring and are classified with a age class (one of those I stated before)
And what I need is the current age of the bird at the current date in one of those categories.
I ringed a bird on 27 July 2015 and it was a 2cy (that bird was born on the previous year) so what I need today (at the current date) is to show the current age, that would be a - 3cy in 2016.
If the bird was a 1cy in July 2015 in 6 January 2016 (current date) would be a 2cy..
And so on for all the other age classes.
Hope it makes sense.
Thank you for your time and all the help.
Instead of a calculation, I suggest you use a script. Since this rollover always happens in January (at the turn of the new year), I would store the most recent year in a single-record table and simply have a script run when you open the database (assuming you can't use server-side scripting; if you can, it's a better option). That script checks to see if the current year is greater than the last year updated, and updates all the bird ages appropriately if it is.
Thank you Mike,
I will try this solution, but since I´m pretty new to filemaker, I will have to try and error the script construction.
Solve the problem:
Just made this calculation:
GetAsText ( Year ( Get ( CurrentDate ) ) - Year (Date of ringing )) + If ( Age = "1cy" ; +1 ; 0 ) + If ( Age = "2cy" ; +2 ; 0 ) + If ( Age = "3cy" ; +3 ; 0 ) + If ( Age = "4cy" ; +4 ; 0 ) + If ( Age = "+4cy" ; +4 ; 0 ) + If ( Age = "Pullus" ; +1 ; 0 )