7 Replies Latest reply on Jan 6, 2016 5:26 AM by HelderCardoso

# How to change value by the end of the year?

Hello,

In order to get the age of a bird (I´m building a birdwatching database) I would need the age value to change after the 31 December. Example:

If I see a bird on 30 July 2015 and its age is 1cy (1 calendar year), I would need that the age would change to 2cy (second calendar year) on Januray 1st 2016.

Thank you for any help.

Cheers,

• ###### 1. Re: How to change value by the end of the year?

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.

• ###### 2. Re: How to change value by the end of the year?

Don't even need the IF, just

(Year (current date)  - Year (bird seen date) )+1

[spelling out date functions as you did, of course]

• ###### 3. Re: How to change value by the end of the year?

True!  Much simpler

• ###### 4. Re: How to change value by the end of the year?

Hello,

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.

Example

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.

• ###### 5. Re: How to change value by the end of the year?

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.

• ###### 6. Re: How to change value by the end of the year?

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.

Cheers,

• ###### 7. Re: How to change value by the end of the year?

Solve the problem: