A READER ASKS: FileMaker Validation For Year

From Dwayne Wright PMP, PMI-ACP, CSM
Certified FileMaker Developer

WEB: www.dwaynewright.com
EMAIL: info@dwaynewright.com
TWITTER: dwaynewright
YOUTUBE: FileMakerThoughts

I am fairly new to FM and am trying to make a solution for my Church.

I have used many of your recourses to get started. Thanks so much for them!

I want to set up validation of a date field so that dates entered can only be of a certain year (using a drop down calendar).

The “In Range” works but the date restriction changes from year-to-year and I don’t always want to have to edit that fields properties each year, but get the restriction from a field on the database.

I am trying to use the validate by calculation, but I can’t seem to find a calculation that will work.

Try using the Year function within your calculation. The year function is found in the Date family of functions and it extracts the year information only from a properly formatted date string in a date field or text field wrapped properly with the GetAsDate function.

For example, the information of 6/1/98 would return 1998 only or 3/17/2010 would simply return 2010. So when you exit the field, the validation would simply check to make sure the year entered equals some other year you specify (either hard coded, based upon another field or via a calculation).

Many times, the year function is used in conjunction with other function as part of a nested function. For example, Get(CurrentDate) returns the current date but what if you just want the current year? Year(Get(CurrentDate) would do the trick.
More info about the author and FileMaker in general, contact me at info@dwaynewright.com.

© 2010 - Dwayne Wright - dwaynewright.com